question

QuantaDialysisTechnologiesLimited-6985 avatar image
0 Votes"
QuantaDialysisTechnologiesLimited-6985 asked MichaelHan-MSFT commented

Microsoft.IdentityModel.SecurityTokenService.RequestFailedException: Token request failed

I have the following CSOM code:-

using (ClientContext context = new PnP.Framework.AuthenticationManager().GetACSAppOnlyContext(RisksiteUrl, clientId, clientSecret, AzureEnvironment.Production))

it was working well for around 1 year, but starting from yesterday the above code will raise this exception:-

Unhandled Exception: Microsoft.IdentityModel.SecurityTokenService.RequestFailedException: Token request failed. ---> System.Net.WebException: The remote server
returned an error: (401) Unauthorized.

Any advice?
Thanks

office-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered MichaelHan-MSFT commented

Hi @QuantaDialysisTechnologiesLimited-6985,

Maybe the client secret expired, so you got this error. By default, client secrets for SharePoint Add-ins that are registered by using the AppRegNew.aspx page expire after one year.

You could renew the client secret: https://medium.com/@cecildt/renewing-sharepoint-online-provider-add-ins-client-secret-ba2828a49e7

Or register a new app to make it work.

Update:

This could be related with the TLS 1.2 enforcement that's being rolled out. Read this article for tetails: https://techcommunity.microsoft.com/t5/microsoft-sharepoint-blog/provider-hosted-app-pha-application-errors-tls-errors-and-401/ba-p/2273611



If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @QuantaDialysisTechnologiesLimited-6985,

Is there anything update? If my reply helps you, you could accept it as answer :)

0 Votes 0 ·