Forum Discussion
MrTimn
Nov 08, 2023Copper Contributor
teamsfx-react@3.0.2 TeamsUserCredential.getToken results in error
The error I am getting when trying to get a teams access token:
Failed to get access token cache silently, please login first: you need login first before get access token.
Code that has the error:
// configure teamsfx-react
const { loading, theme, themeString, teamsUserCredential } = useTeamsUserCredential({
initiateLoginEndpoint: `${process.env.REACT_APP_INITIATE_LOGIN_ENDPOINT}/auth-start.html`,
clientId: process.env.REACT_APP_AAD_APP_CLIENT_ID as string
});
// calling getToken
const scopes = [
"openid",
"profile",
process.env.REACT_APP_API_SCOPE as string,
];
// Throws the "please login first" error
const token = await teamsUserCredential?.getToken(scopes)
The issue is only occurring on "New Teams" for Mac. The same code works on "New Teams" on Windows.
Logging in solves the issue temporarily, if I close teams and open it again I am forced to login again.
I have been trying to figure out this issue for weeks.
- Sayali-MSFTMicrosoftMrTimn-Thanks for reporting your issue.
We will check this at our end and will get back to you.- MrTimnCopper ContributorMy application is using Application Insights, so I may be able to provide more information.
Let me know if there is anything I could provide that would help you troubleshoot the issue.
Thanks - MrTimnCopper ContributorI am using New Teams on Mac:
Version: 23285.3805.2505.9215
ClientVersion: 50/23101227708- Sayali-MSFTMicrosoftMrTimn -We are checking this issue with the internal team; we will let you know once we have any update.
- shabbirdhangotCopper Contributor
We are also facing similar issue with our production application. Kindly provide urgent resolution for the issue. I have reported issue to TeamsFx side as well. Following is Github issue link for the same: https://github.com/OfficeDev/TeamsFx/issues/10379
- Sayali-MSFTMicrosoftshabbirdhangot - If you have any business-critical issue which need immediate attention, please raise a support request here:
https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-support?view=o365-worldwide&tabs=online