Forum Discussion

wmmihaa's avatar
wmmihaa
New Member
10 years ago

How to use the oAuth refresh token to acquire a new token?

Is there anyone who could tell me how to use the refresh token to get a new token. I've read through the AAD documentation on the subject, But all I get is: "AADSTS50012: Invalid client secret is provided."

2 Replies

  • joespiff's avatar
    joespiff
    Regular Visitor

    I've had success with this:

    using Microsoft.IdentityModel.Clients.ActiveDirectory;

    public void Refresh(string authorityUri, string ClientID, string ClientSecret, string RefreshToken)
    {
    TokenCache TC = new TokenCache();
    AuthenticationContext AC = new AuthenticationContext(authorityUri, TC);
    ClientCredential cc = new ClientCredential(ClientID, ClientSecret);
    AuthenticationResult AR = AC.AcquireTokenByRefreshToken(RefreshToken, cc));
    }
    • joespiff's avatar
      joespiff
      Regular Visitor

      } // my initial post didn't include the final curly bracket.