question

RaviNalla-5313 avatar image
1 Vote"
RaviNalla-5313 asked chandras-2479 commented

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

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

azure-ad-authentication-protocols
· 3
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.

I have the same issue but mine is a little bit different. It's working fine with me when i'm running on my local machine. but i'm getting the error when deployed to the server.

1 Vote 1 ·

Since it is working on my local machine (Windows 10) and NOT working on the old dev server (Windows 2008) I started to hint that it has something to do with the server.

Today I tried deploying the application in a Windows Server 2012 and it works perfectly as expected.

So I think it has to do with the server.

0 Votes 0 ·
chandras-2479 avatar image chandras-2479 CanayaJhun-0507 ·

I am also having same issue, it works fine on my local PC, however, it throws "Token Request Failed" when launched on the Dev Server(ours is latest Windows server 2019, still having the issue), it suddenly stopped working about 20days back. - any thoughts or suggestions

0 Votes 0 ·
NigelH-1818 avatar image
0 Votes"
NigelH-1818 answered

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)

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.

NigelH-1818 avatar image
2 Votes"
NigelH-1818 answered PrasathSiva-1844 commented

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.

· 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.

I have upgraded to .Net Framework 4.8 too but still getting the same error. I have this issue only the server (Windows Server 2012 R2). It is working on my local. Any help will be appreciated.

I have adding code to explicitly specify TLS 1.2 still no luck.

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

0 Votes 0 ·
MuhammadAltaf-1865 avatar image
0 Votes"
MuhammadAltaf-1865 answered

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.

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.