Tushar Das
Tushar Das

Reputation: 59

Can I regenerate access token and refresh token pair if my client secret expires?

I have an App registered in Azure and the client secret has expired. For the same client secret can the access token be regenerated using the refresh token last received?

Just to be clear, the ask here is for access token when the client secret expires and not when the access token expires.

Upvotes: 0

Views: 819

Answers (1)

Rukmini
Rukmini

Reputation: 15874

Note that, If the client_secret is expired you cannot generate access and refresh tokens. One must create the new secret and then try to generate the tokens.

Using the expired client_secret leads to failure in generation of tokens and will get error like below:

enter image description here

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

I generated access and refresh token using below parameters in Postman:

GET https://login.microsoftonline.com/TenantId/oauth2/v2.0/token

client_id:ClientID
client_secret:ClientSecret
scope:https://graph.microsoft.com/.default offline_access
grant_type:authorization_code
redirect_uri:RedirectUri
code:code

enter image description here

To refresh the access token, I used the below parameters:

https://login.microsoftonline.com/TenantID/oauth2/v2.0/token

client_id:ClientId
grant_type:refresh_token
refresh_token:refreshtoken
client_secret:ClientSecret

enter image description here

Upvotes: 1

Related Questions