3

How can I get a Microsoft graph refresh token using java SDK? I am using java SDK of graph and got the access token. How can I get a refresh token in java SDK using this accessToken?

theduck
  • 2,589
  • 13
  • 17
  • 23
User1290
  • 59
  • 9
  • 2
    Does this answer your question? [How to refresh a token for Microsoft Graph](https://stackoverflow.com/questions/51153055/how-to-refresh-a-token-for-microsoft-graph) – Maxim Sagaydachny Jan 03 '20 at 13:16
  • No. I am using Java SDK. Let's say i have got a graphClient initialized using the access token. Now the token will surely expire after 59 minutes.According to this initialized graphclient should stop working. How can I get the refresh token or update graphclient in Java SDK – User1290 Jan 04 '20 at 06:22
  • Or is it like if "once graphclient is initialized using access token you can use it as long as you want without any need to re-initialize it." – User1290 Jan 04 '20 at 10:02
  • answer https://stackoverflow.com/a/51161027/12396017 describes the use of grant type REFRESH TOKEN and SDK contains method which does such thing - com.microsoft.graph.auth.BaseAuthentication -> getAccessTokenSilent() -> setGrantType(GrantType.REFRESH_TOKEN) - I vote to close this question as an duplicate – Maxim Sagaydachny Jan 05 '20 at 04:33

1 Answers1

1

For Client credential flow, you don't get the refresh token. You can simply request a new access token again. A better idea will be to use https://github.com/microsoftgraph/msgraph-sdk-java-auth for auto-refresh of access token which will save you a lot of programming efforts