클라이언트 자격 증명 흐름 (데몬)을 사용하여 Microsoft Graph API에 액세스 할 때 "테넌트 GUID에 대한 테넌트가 없습니다."

루이스 구 베이 아

Outlook 사서함에서 데이터베이스로 메시지를 복사하기 위해 콘솔 응용 프로그램에서 주기적으로 Microsoft Graph에 액세스하고 싶습니다. 프로그래밍 방식으로 인증하려면 Microsoft Graph의 "클라이언트 자격 증명 흐름"을 사용해야했습니다.

내가 취해야 할 단계는 다음과 같습니다.

  1. Azure Portal에 앱을 등록하고 이에 대한 클라이언트 암호를 만듭니다.
  2. 필요한 모든 권한을 추가하고 액세스 권한을 부여합니다.

    필요한 권한을 추가하고 관리자 액세스 권한을 부여합니다.

  3. 관리자가 처음 액세스하여 해당 권한을 확인하도록합니다. 이는 다음 URL을 사용하여 수행됩니다.

    https://login.microsoftonline.com/{tenant}/v2.0/adminconsent
    ?client_id={app id}
    &state=1234
    &redirect_uri=https://login.microsoftonline.com/common/oauth2/nativeclient
    &scope=https://graph.microsoft.com/.default
    

    다음과 같은 응답을 받았습니다.

    admin_consent: True
    tenant: ca566779-1e7b-48e8-b52b-68**********
    state: 12345
    scope**: scope: https://graph.microsoft.com/User.Read https://graph.microsoft.com/.default
    

    (The scope might explain the problem described later here: Why do I only get User.Read when I've configured 13 different permissions??)

    관리자 자격 증명을 사용하여 권한 확인

  4. Get an access token (with success!):

    Access token obtained

  5. Try to read users (with success):

    users list obtained with success

  6. Try to read my own emails (without success):

    no luck with own emails

  7. Try to read somebody else's emails (the user was invited to access the app as a guest, but still, no success):

    no luck trying to read guest's emails

I don't understand why I can't read Messages but I can read Users. It seems the permissions were completely ignored (I confirmed that I don't need any permission to read the users).

UPDATE

This is my tenant name:

enter image description here

These are the users added to the tenant:

enter image description here

Important: I don't own an office 365 subscription in my Azure AD. All these emails belong to a different AD.

The previous question "The tenant for tenant guid does not exist" even though user is listed on users endpoint? is similar to mine but I believe this is not a duplicate as my problem is slightly different and the proposed solution uses OAuth1 (I am using OAuth2).

Marc LaFleur

Microsoft Graph can only access data within the tenant you have authenticated to. This means that you cannot access a mailbox from another tenant, even if that User is a guest in the tenant you authenticated to. Allowing this would violate the fundamental principle of data isolation in AAD/O365 tenants.

It is also important to note that AAD/O365 and Outlook.com are distinct platforms. Microsoft Graph's core value prop is a common API layer across AAD and MSA, but under the covers, they are calling into distinct backends.

Beyond data isolation and these being distinct platforms, Outlook.com simply does not support Application Permissions (Client Credentials). You can only access Outlook.com using delegated permissions, and even only a limited set of scopes are supported:

Not all permissions are valid for both Microsoft accounts and work or school accounts. You can check the Microsoft Account Supported column for each permission group to determine whether a specific permission is valid for Microsoft accounts, work or school accounts, or both.

포함 된 범위와 관련하여 여기서 문제는이 테넌트에 O365에 대한 라이선스가 없다는 것입니다. 구독없이 동의 할 수있는 경우 이론상 나중에 구독이 추가 될 때 앱이 예기치 않게 동의를받을 수 있습니다. 즉, 당신이 돌려받는 실제 토큰의 예를 보지 않고는 말하기가 어렵습니다 (이것을 더 살펴 보길 원하는 사람 중 하나를 자유롭게 게시하십시오).

마지막으로 juunas/me. /me세그먼트는 "현재 인증 된 사용자"의 별칭입니다. 클라이언트 자격 증명을 사용할 때 사용자를 인증하는 것이 아니기 때문에은 /me효과적으로 null입니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관