{"id":8419,"date":"2021-08-04T19:22:35","date_gmt":"2021-08-04T19:22:35","guid":{"rendered":"https:\/\/blogs.aaddevsup.xyz\/?p=8419"},"modified":"2021-08-04T19:22:39","modified_gmt":"2021-08-04T19:22:39","slug":"microsoft-graph-why-you-cannot-call-the-me-endpoint-with-a-token-acquired-via-the-client-credentials-grant-flow","status":"publish","type":"post","link":"https:\/\/blogs.aaddevsup.xyz\/2021\/08\/microsoft-graph-why-you-cannot-call-the-me-endpoint-with-a-token-acquired-via-the-client-credentials-grant-flow\/","title":{"rendered":"Microsoft Graph: Why you cannot call the “me” endpoint with a token acquired via the client credentials grant flow"},"content":{"rendered":"\n
Introduction<\/strong><\/p>\n\n\n\n Microsoft Graph has a couple of primary ways you can get information about a user in Azure AD. This not only includes things like the user attributes but also groups the user is a member of, access to mail, and etc. Each endpoint does require specific permissions but generally speaking, a user can get the basic information about him\/herself via the “me” endpoint.<\/p>\n\n\n\n The “me” endpoint<\/strong><\/p>\n\n\n\n From our docs <\/a>page, there is a note that you must have a signed in user in order to use the “me” endpoint:<\/p>\n\n\n\n Calling the The reason why you cannot use this when calling it with a token obtained with the client_credentials <\/a>grant flow is that you do not have a user context. This particular flow only involves application sign-in using its own identity ( client id and client secret or certificate ). As a result, it has an Application token. Here is a sample token that was obtained when I signed in to get the token. You will notice that there is information in this token about the user ( myself ) as well as a scp ( Scopes ) claim:<\/p>\n\n\n\n\/me<\/code> endpoint requires a signed-in user and therefore a delegated permission. Application permissions are not supported when using the
\/me<\/code> endpoint.<\/span><\/em><\/p>\n\n\n\n