Azure Active Directory B2C, Postman get access token without browser interaction

Viewed 103

We have an API which we use for our .NET application, but we also want to make calls directly from postman. The current setup uses the Authorization Type OAuth 2.0 build in functionality of postman. Which opens a popup of our Azure AD B2C sign-in screen.

enter image description here

We are using custom policies to sign-in here as well.

My question is, is there a way to simply use postman (preferably in 1 request) to get the access token without having to use the browser and sign-in manually?

1 Answers

I tried to reproduce the same in my environment and got the below results:

As mentioned by Jas Suri, you can make use of ROPC Flow to generated access token without browser interaction.

I created an Azure AD B2C application and enabled Allow public client flows option:

enter image description here

Please note that, if you do not want to enable Allow public client flows , you can create client_secret and give the parameter in Postman while generating the token

Now I created ROPC User flow like below:

enter image description here

I generated the access token using ROPC flow via Postman with parameters like below:

POST  https://tenant.b2clogin.com/tenant.onmicrosoft.com/policy/oauth2/v2.0/token

grant_type: password
client_id: appid
scope:  https://tenant.onmicrosoft.com/web_api/api.read
username: yourusername
password: *****

Response:

enter image description here

When I decoded the token, I can find the scp claim successfully like below:

enter image description here

Related