AADHttpClient authentication fails in MS Teams desktop client after user changed password
Category
- [x] Bug
Describe the bug
We are loading an SPFx webpart into a personal MS Teams app. When using this application in the desktop client, when using AADHttpClient in the webpart, the auth flow fails after a user has changed his password, even after waiting a couple of days. In the web client the issue doesn't occur.
The issue occurs in the call to Microsoft.SharePoint.Internal.ClientSideComponent.Token.AcquireOBOToken, which returns the following error:
{"odata.error":{"code":"10001","message":{"lang":"en-US","value":"AADSTS50173: The provided grant has expired due to it being revoked, a fresh auth token is needed. The user might have changed or reset their password. The grant was issued on '2019-12-18T13:53:05.0728393+00:00' and the TokensValidFrom date (before which tokens are not valid) for this user is '2020-02-06T08:34:15.0000000Z'.\r\nTrace ID: f5a28c6d-bd35-4f3c-a0e5-e65d5d261900\r\nCorrelation ID: 855d349f-405f-b000-e134-72e59f622787\r\nTimestamp: 2020-02-11 09:54:02Z"},"error.redirectUrl":"https://
.sharepoint.com/...?reauthid=2.MXwwfA.Ec3DKPGt_1Gm0Ag....."}}
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We have a customer where one of the users is experiencing the exact same issue.
Did the user logout/login after changing their password? Seems the access token is cached from the initial login & changing the password invalidated the token.
I tried it all :( logout/login, quit Teams, reboot, change to developer mode and back, etc ... No luck ...
What helped in the end was explicitly navigating to the URL provided in error.redirectUrl within teams (through the debug console). This is however not something we can let all end-users do whenever they have the issue...
Seems like this could and should be handled internally when it occurs.
eek... agreed, that's not a great experience...
/cc @patmill @lucabandMSFT - is this a known thing or something you were looking into with the improvements to SPFx & the MSTeams integration?
@NickSevens, our customer is authenticating via ADFS, is it the same setup in your case?
@Ollzi we used to but not anymore.
@patmill, @lucabandMSFT, @andrewconnell we have investigated this further with our customer and it was solved with the solution you suggested @NickSevens.
The following error information is returned in the error message when this happens:
{odata.error: {code: "10001", message: {lang: "sv-SE",…},…}} odata.error:{code: "10001", message: {lang: "sv-SE",…},…} code:"10001" error.redirectUrl:"https://xxxxx.sharepoint.com/sites/provisionering/SitePages/Provisioning.aspx?reauthid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" message: {lang: "sv-SE",…} lang:"sv-SE" value:"AADSTS50173: The provided grant has expired due to it being revoked, a fresh auth token is needed. The user might have changed or reset their password. The grant was issued on '2020-01-08T08:31:15.0750000Z' and the TokensValidFrom date (before which tokens are not valid) for this user is '2020-01-16T07:57:14.0000000Z'."
adding @lahuey for awareness... Glad that was solved. indeed that's not something customers can do to solve the issue..
@lucabandMSFT @andrewconnell thanks for the followup.
We've indeed managed to help most people with the workaround mentioned above, but I do hope there will be a fix implemented soon. Company policy makes us change passwords pretty often, so we can't expect users to do this every 2-3 months :)
@ollzi glad it helped for you as well.
@NickSevens said:
we can't expect users to do this every 2-3 months
If the link is provided in the error object, wouldn't you then be able to detect it & handle it in the solution?
@andrewconnell the link is provided in the error response of https://<tenant>.sharepoint.com/_api/Microsoft.SharePoint.Internal.ClientSideComponent.Token.AcquireOBOToken?resource=<guid>&clientId=<guid>, which is not something we call ourselves, but I assume is coming from within AadHttpClient - and is only called on Teams desktop client (and if I recall correctly also in Android/iPhone apps)
Seems to me this should be handled internally by SPFx, to acquire a correct token?
Agreed... seeing Internal in the endpoint says "not for use by 3rd party... it's MSFT so..."

Any updates on this?
@andrewconnell do you have any update on this? We saw the same issue occurring with an MFA being expired. The "solution" redirect URL was again in the response message, so using that message to redirect the user again fixed the issue. This again feels like something that could be done automatically by the calling function when such a response is received.
Nope... I'm not in MSFT engineering so it's not for me to share updates. @lucabandMSFT & @lahuey are on the thread... any updates would be more appropriate to come from them.
@lucabandMSFT @lahuey any update on this in the meantime?
@lucabandMSFT @lahuey We're encountering this issue at multiple customers now as well. Explaining the end-users to open up dev tools and so on to fix it, is really annoying. Is there any progress/movement here? Something we can tell our customers in the meantime?
We have found another company hitting the issue with SPFx teams parts, but only on pinned apps, not on the channel tab with the same app, and they only see it on IPad clients.
I have several customers with conditional access setup with login session time limited. I can easily reproduce this issue using a very narrow window of login time.
The refreshtoken is cached and should be replaced when logging out and in in the client itself. This is a really bad experience.
This should be handled internally as several others stated. If not how can you script a redirect against this url without hitting cors issues? Ive been trying with crossdomainrequest method. The only thing that seems to be working but is terrible is opening the redirect as a deeplink which opens a browser.
Kind regards johan