TIL: You can’t get access tokens to more than one resource in a single call

A colleague was trying to get access tokens via a call like this:

It worked, but then when he tried to access the resource it failed.

I took a look at the access token and found that in case of the above call he was getting a token that looked like this:

See, it is for only one of the resources and for the scope we requested for that resource (api://{anotherAppId}/access.user). Interesting.

I asked him to flip the order such that the Power BI scopes were first. Now the token response only included the Power BI scopes.

So, lesson learnt. You can only get tokens for a single resource per call. I asked my colleague to make multiple calls for each of the resources, with their respective scopes, and now it works.

Later, Googled, and found others too confirming the same (e.g. here and here).