Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

How to get access code again after O365 account is connected #271

@ritushukla

Description

@ritushukla

Hi Team,
How we can get access token again If access token is expired or want to get new token (refresh token) without customer re-authentication in Msal. Previously we were using adal and below is the code.

AuthenticationContext context = new AuthenticationContext(config.getAzureOAuthAuthority(), true, service);
context.setProxy(ProxiedJdkHttpUrlConnectionSource.INSTANCE.getProxy());
Future future = context.acquireTokenByRefreshToken(refreshToken, credential, null);

I am trying below code but it is not working.

final ConfidentialClientApplication app =
ConfidentialClientApplication.builder(
config.getAzureOAuthClientId(), ClientCredentialFactory.createFromSecret(config.getAzureOAuthClientSecret()))
.authority(config.getAzureOAuthAuthority())
.build();
SilentParameters parameters = SilentParameters.builder(
Collections.singleton("https://graph.microsoft.com/.default"),
app.getAccounts().join().iterator().next()).build();
CompletableFuture future = app.acquireTokenSilently(parameters);
result = future.get();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions