Azure-Samples / ms-identity-java-webapp

A Java web application calling Microsoft graph that is secured using the Microsoft identity platform
MIT License
118 stars 105 forks source link

AcquireTokenSilently without Specifying Scopes #76

Closed javate closed 3 years ago

javate commented 3 years ago

I need to refresh the access token but I don't want to specify scopes in SilentParameters. I want to refresh it for all possible scopes which are founded in TokenCache object also.

So, can I reach scopes in the TokenCache? and then I can pass s SilentParameters. Or is there another way for this?

For example like below, It was passed "User.Read" however I don't want to specify any scope. I only want refresh my current access token(which is also founded in TokenCache) silently. How can I do that?

app.tokenCache().deserialize(tokenCache.toString());
SilentParameters parameters = SilentParameters.builder( Collections.singleton("User.Read"),result.account()).build();
CompletableFuture<IAuthenticationResult> future = app.acquireTokenSilently(parameters);
IAuthenticationResult updatedResult = future.get();
Avery-Dunn commented 3 years ago

Closing this question, since everything is being covered in this duplicate thread: https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/375. If you have issues or questions specific to this sample, feel free to re-open or leave a comment.