Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,956 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We are developing Microsoft Sharepoint "Widgets" using javascript(React) and aadTokenProviderFactory to acquire tokens.
import { WebPartContext } from "@microsoft/sp-webpart-base";
async function getMSToken(context: WebPartContext) {
const provider = await context.aadTokenProviderFactory.getTokenProvider();
const token = await provider.getToken('https://graph.microsoft.com');
return token;
}
This token is valid and everything works fine. But when switching users I receive a token from the old user. How to solve this issue and acquire tokens for the user that is currently signed in?
getToken method has 2nd parameter called useCachedToken: aadtokenprovider. Try to pass false there:
const token = await provider.getToken('https://graph.microsoft.com', false);