Failed to get accesstoken with AADTokenProvider on SharePoint mobile app
Category
- [ ] Question
- [ ] Typo
- [x] Bug
- [ ] Additional article idea
Expected or Desired Behavior
I created a SharePoint Framework 1.7 webpart which uses the AadTokenProviderFactory to generate an accesstoken. We've tested this on all browsers (desktop and mobile) and this is working as expected.
Observed Behavior
However, when opening a page containing the webpart on the SharePoint mobile app (Version 3.8.0) the webpart receives an error:
"TypeError: Failed to fetch"
Steps to Reproduce
this.context.aadTokenProviderFactory
.getTokenProvider()
.then((tokenProvider: AadTokenProvider): Promise<string> => {
// retrieve access token for the enterprise API secured with Azure AD
return tokenProvider.getToken('[Azure AD app ID]');
})
.then((accessToken: string): void => {
alert(accessToken);
}).catch(error => {
alert('error: ' + error);
});
Also tried to update the AD app manifest with
"preAuthorizedApplications": [
{
"appId": "00000003-0000-0ff1-ce00-000000000000",
"permissionIds": [
"[PERMISSION ID]"
]
}
]
but still no luck.
Any ideas?
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
@LeemansBE said:
Also tried to update the AD app manifest with
What do you mean by this... where did you do this? Are you saying you're modifying the Azure AD app manifest in the Azure AD Admin Portal? If so, that will not have an impact here...
Where is the error coming from... when you obtain the token provider (the first then()) or when you try to get the token?
Hi @andrewconnell
Jep that is correct. I've tried to follow the steps described here
Obtaining the token provider seems to be going well. The error is thrown when we try to get the token. It's actually quite hard to debug as this works well on all browsers (dekstop and mobile) but only fails when rendered in the SharePoint app (Android).
We can also confirm we have had issues when using the SharePoint app and using the Graph authentication package. Works fine when in the browser on the same Android/iOS device but fails to auth in the SP app. I will query my team for further info and get back to you.
According to #4013, @lucabandMSFT said this same process should work for the mobile app.
@lucabandMSFT is it the same AppID for the mobile app?
yes, exactly the same. as we load the SharePoint page in an iFrame in the Mobile app (or Team). it's the page that goes to AAD to fetch the token.. which means that it is the same appID.
closing this as a dupe of #4013
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues