I have a azure web api where it access sharepoint and get details from a list using client id client secret.
In last couple of months it suddenly started giving the below error
Microsoft.IdentityModel.SecurityTokenService.RequestFailedException: Token request failed. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2WebRequest.GetResponse()
at Microsoft.IdentityModel.S2S.Protocols.OAuth2.OAuth2S2SClient.Issue(String securityTokenServiceUrl, OAuth2AccessTokenRequest oauth2Request)
I have already tried the below cases
1)Client id/Secret is still valid, I have already checked that
2) Tried using a new client id and client secret to access SharePoint, by updating web.config using app service editor in azure web api
3)There were no changes done to the code everything was working fine till last month.
4)Tried Accessing the SharePoint site through PowerShell using same client id and secret this works fine without issue.
Any pointers would be helpful