FE ->(token_a) Middleman ->(token_b) DownstreamServiceA
My understanding is that, for the Middleman to make API calls to DownstreamServiceA, it needs to exchange for token_b using token_a. I tried to simulate this behaviour in postman. But I am unable to exchange for token_b using token_a. I get the following error
AADSTS65001: The user or administrator has not consented to use the application with ID '{my-middleman-clientid}'
On the Azure Portal, I have configured the FE API permission to have access the exposed API scope of DownstreamServiceA & Middleman. Granted admin consent on behalf of my organisation users at that too.
Getting token_a
POST to https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
grant_type:password
client_secret: foobar
client_id: my-fe-clientid
username: awesome
password: bar
scope: api://{MiddlemanId}/Middleman.All
Exchange for token_b
POST to https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
grant_type: urn:ietf:params:oauth:grant-type:jwt-bearer
client_id: my-middleman-clientid
client_secret: foobar
scope: api://{DownstreamServiceAId}/ServiceA.all
assertion: {token_a}
requested_token_use: on_behalf_of
May I know what am I doing wrong? My understanding is that my FE needs to request and grant permission for the DownStreamServiceA scope upfront, which I did with an admin grant on the Azure Portal.