Refresh Bearer Token

334 views Asked by At

I am working in a Power Automate solution which does read data from O365 via Graph API. As, the operation is running more than an hour, the bearer token gets expired.

I have implemented a logic to perform an REST call to regenerate the Bearer Token whenever it fails from the refresh token and ran the failed operation again in a DoUntil loop. But, as I have many calls performed via Graph API , I need to write the logic elsewhere in the Flow.

Pls do let me know whether there are any simple way to regenerate the Bearer Token from the Refresh Token.

Any help would be appreciated!!!

2

There are 2 answers

0
Dhivya G - MSFT Identity On

We would recommend start looking at the samples published by Microsoft. Microsoft recommends using MSAL library and MSAL library provides token caching and get fresh token when it's getting close to expiration. For more details on token caching please refer this documentation.

0
Ansar On

Store the token in a variable and use a parallel branch and get a new token in every 15 or 20 minutes. User the token variable in all API calls