[Question] How to access refresh token
See original GitHub issueHi I need to keep refresh token in the database to sync up with client’s inbox. I couldn’t find any legal way to retrieve a refresh token from the IAuthenticationResult. I think up with temporal dirty workaround using reflection:
try {
//see com.microsoft.aad.msal4j.AuthenticationResult#refreshToken
final Field refreshTokenField = credentials.getClass()
.getDeclaredField("refreshToken");
refreshTokenField.setAccessible(true);
return refreshTokenField.get(credentials).toString();
} catch (IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e);
}
Is there better anyway to retrieve a refresh token? Serialize TokenCache doesn’t look much better for me.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
What Are Refresh Tokens and How to Use Them Securely
This post will explore the concept of refresh tokens as defined by OAuth 2.0. We will learn how they compare to other token...
Read more >Question about access token and refresh token in google API
Currently, I am using OAuth 2.0 to access Google APIs. I got access token and refresh token, used the access token to connect...
Read more >JSON Web Tokens | Access and Refresh Tokens - YouTube
Discussing JWT's with @Joseph Branch, @James Q Quick and @Colby Fayock "How to Store JWT for Authentication" by @Ben Awad - I'd strongly ......
Read more >OAuth Access & refresh token questions - API and Webhooks
Yes, if a user logins in on a different device, the OAuth flow basically restarts, invalidating the current OAuth access and refresh tokens...
Read more >Retrieve an Access Token and Refresh Token
Using Refresh Tokens ... Access tokens will expire after a set time period (normally returned in the expires_in parameter). When you obtain an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sleshJdev Does ‘acquireTokenSilently’ work for your scenario? MSAL doesn’t expose the refresh token but instead takes care of refreshing the access token for you. When you acquire a token with any of the APIs, MSAL will store the refresh token in an in-memory cache, which you can save to disk.
AcquireTokenSilently()
will first look into the cache, see if you have a valid access token, and if not then will try to refresh the refresh token.Closing this issue as the question has been answered above.