Friday, August 26, 2016

Postman : Using cURL to send OpenID Connect / OAuth to Azure AD / ADFS

"cURL is a computer software project providing a library and command-line tool for transferring data using various protocols".

I discovered that Postman allows you to generate these commands.

There are Postman collections for Azure AD / ADFS in gists as per Postman : Using Postman to get "Userinfo" on ADFS and the link inside the post.

So if you load the collection into Postman, click on "Generate Code" (top right) and then in the dropdown, select "cURL".

e.g.

curl -k -X POST -H "Content-Type: application/x-
www-form-urlencoded" -H "Cache-Control: no-cache" -H "Postman-Token: 0303470d-5a
3b-bdea-9da3-9ab3e12f66ce" -d "client_id=37f...0b0e&scope=openid&redirect_uri=https://localhost:1234&grant_type=authorization_code&client_secret=Rel...G9&code=Nj...WWg" "https://my adfs/adfs/oauth2/token"


{"access_token":"eyJ...GFQ",

"token_type":"bearer","expires_in":3600,
"resource":"urn:microsoft:userinfo","
refresh_token":"TT9...u21w",
"refresh_token_expires_in":25768,
"scope":"openid","id_token":"eyJ...Ywg"}


If you use self-signed certificates you need to use the "-k" option.

Enjoy!

No comments: