I am supposed to get Access token from Azure AD using SDK java ( i have the clientid, clientSecret and tenantId), and send the Access token to the UI. Next this token is sent in the request headers of an api call and i need to use this access token to call users, groups and so on. I could figure out the code as below to get the access token.
AccessToken tokenSync = new ClientSecretCredentialBuilder()
.clientId(clientId)
.clientSecret(clientSecret)
.tenantId(tenantId).build().getTokenSync(null);
The above code gives me the access token and this is sent to the UI and then the same token is sent back to call the users, groups api using SDK java.
How can i use this token to call user and groups ?
Using this token can i get the GraphClient to call the api such as users, groups ?
How can i validate whether this token is expired and re-generate a new token using the above code.
I am unable to find methods to use the same access token and do subsequent calls to groups and users using SDK java. Any help/suggestions please