vfirma
vfirma

Reputation: 370

oAuth2.0 with Microsoft flow(Power Automate) and then accessing protected API

I'm working on setting up a Microsoft flow that will need to access a registered web app, which utilizes oAuth2 authentication. The purpose of this would be to obtain a JWT access token that will be used to access the protected API in the web app. I don't have a lot of experience with Microsoft Flow so I'm wondering how one would login through Auth2 with Username/Password and retrieve the token.

Upvotes: 6

Views: 28513

Answers (2)

vfirma
vfirma

Reputation: 370

I was able to solve this using custom connectors. If you don't have 2FA setup on your account, Hury's answer works just as well.

Upvotes: 0

Hury Shen
Hury Shen

Reputation: 15734

You just need to use "HTTP" connector to get the access token and use this token to request your app. Please refer to the steps below:

  1. You need to know this OAuth2.0 flow to request an access token:
https://login.microsoftonline.com/{your tenantId}/oauth2/v2.0/token

For this step, you can refer to this tutorial, and I think you have already known how to get the access token by OAuth 2.0 resource owner password credentials grant in postman.

  1. Then we can do this operation(get the access token) in Microsoft Flow(power-automate). enter image description here

Please replace the {tenantId} and xxxxx above with your own information.

  1. After running this Microsoft flow, we can get the access token successfully. enter image description here

  2. If you want to use this access token in the following actions in your Microsoft flow, you can use "Parse JSON" action to parse the response body from the HTTP action and then use the access token(shown as below screenshot) enter image description here

Upvotes: 8

Related Questions