'What's the difference between User.Read and OpenID+Profile+Email scopes
Does User.Read "contain" the permissions email openid and profile? I've found that apps that are requesting the 3x scopes, can instead accept just the User.Read permission and still function equivalently
At work I'll get requests from the business to help them setup SSO using OIDC, and I'm not actually sure what permissions I should be giving them. Seems like either option works but I'd like to better understand what's happening
See my observations below:
I've created a basic Function App, and configured it to use OpenID Connect Image
My App Registration already has the
User.Readpermission with admin consent, so when I log into my Function, there's no issue. ImageHowever, after removing the
User.Readpermission and logging in, I now get a permissions request prompt ImageAnd after consenting to the permissions, I can now see that
emailopenidandprofilepermissions were added ImageEven more interesting, the permissions in the request prompt correlate to
openidandoffline_access, butoffline_accesswasn't added, whileemailandprofileweren't in the request
I did find a similar question, but the accepted answer doesn't seem to align with what I see here
Solution 1:[1]
User.Read is a scope intended to be used when requesting an access token for the Microsoft Graph API. It grants privileges to read the profile of the signed-in user only. A separate call to the Microsoft Graph API is required to retrieve the profile.
openid, email, profile and offline_access are OpenID Connect scopes:
openidis used to request an id token.offline_accessis used to request a refresh token which can later be used to get a new access token.emailto request an email claim.profileto request several user claims (Eg.preferred_username).- Both
emailandprofilecan be used to augment information available in the UserInfo endpoint, however, it is recommended to use the id token which is already a superset of the information available at the aforementioned endpoint.
Hope this helps.
Solution 2:[2]
Generally I would favour the OAuth standard design where fields like these are Personally Identifiable Information (PII). So each app should only use the smallest scope it needs, as an information disclosure best practice. See also this Curity article.
- Name
- Phone
- Address
The Graph API can also be used with standard scopes, as in step 11 of this blog post of mine, where I wanted to get hold of user info in an API. So if this works for you I would prefer it. Personally I also prefer standard scopes so that my application code is portable.
Microsoft's design is based on each API requiring a different access token, the resource indicators spec. It is interesting, though perhaps not always intuitive. I am no expert on Azure AD though, and there may be some intended usage I do not understand.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | AlfredoRevilla-MSFT |
| Solution 2 | Gary Archer |
