SP Online App Authentication failing with "Token Request Failed" error

Ravi Nalla 106 Reputation points
2021-05-18T03:11:28.067+00:00

We had SP App for SPOnline which is working fine earlier. But now suddenly few customers are getting "Token Request Failed" when app authentication validated via CSOM.
Is there any change in Microsoft Authentication Model recently?

Below stack trace message
An unexpected error has occured. Details of the problem are: Token request failed., Stack trace: at Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request) at TokenHelper.GetAppOnlyAccessToken(String targetPrincipalName, String targetHost, String targetRealm)

We checked App Client Secret not expired.

Any help is much appreciated. Thanks in advance

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,376 questions
{count} votes

4 answers

Sort by: Most helpful
  1. NigelH 11 Reputation points
    2021-05-21T13:35:45.653+00:00

    Got a response from Premier Support suggesting to change the DotNET framework to 4.6 or higher, as they think it's to do with the depreciation of TLS 1.0 & 1.1. We're running tests now.

    2 people found this answer helpful.

  2. NigelH 11 Reputation points
    2021-05-20T10:28:21.6+00:00

    I've been experiencing the same sort of issue since 22 April, in 3 separate applications, and have yet to find a resolution. Support ticket has been open with Microsoft for a week now with no progress. My errors are:

    SharePointPnP.IdentityModel.Extensions.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)

    The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at SharePointPnP.IdentityModel.Extensions.S2S.Protocols.OAuth2.OAuth2WebRequest.GetResponse() at SharePointPnP.IdentityModel.Extensions.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)

    0 comments No comments

  3. Muhammad Altaf 1 Reputation point
    2021-06-14T03:08:06.303+00:00

    Hi NigelH,
    I am also facing same issue. my application is running on windows server 2019. and it works on local pc but does not work on the server as previously was working suddenly stop working.

    0 comments No comments

  4. John Guilbert (Housing) 1 Reputation point
    2023-08-10T17:15:27.6833333+00:00

    I have same issue after coming back from holiday. Debug on local machine I get this, but it works fine on Live Production as Azure App Service. Did anyone resolve?

    0 comments No comments