androidmicrosoft-graph-apiazure-ad-graph-apiyammermicrosoft-graph-sdks

Multipe Scope not working, Use Microsoft Graph API SDK


I have registered an app in the Azure AD portal and given Microsoft Graph API permissions to fetch user data (user.read.) and yammer feeds.

Note: the app is also registered with the yammer portal.

App auth is working fine if I have used a single scope but it fails in case of multiple scopes.

cases :

Working fine in single scope case val SCOPES = arrayOf("https://graph.microsoft.com/.default")

Not Working in multiple scope case val SCOPES = arrayOf("https://graph.microsoft.com/.default", "https://api.yammer.com/user_impersonation")

We are using Graph SDK in Android.

Thanks in Advance.

please suggest a way to achieve the solution.


Solution

  • You have set two scopes from different resources, which is not supported.

    Because, finally you will get an Azure AD access token. However, the aud claim in the token can only represents one resource.

    enter image description here


    Conclusion:

    1. You can add more than one scopes from one resource. For example: https://graph.microsoft.com/User.Read.All, https://graph.microsoft.com/Mail.ReadWrite and other scopes from Microsoft Graph.

    2. If you want to get token for more than one resource, you need to get tokens for them separately.