user5661230
user5661230

Reputation:

System.Net.Http.WinHttpException: A security error occurred

I'm getting the following error while trying to obtain an access token from ADFS 2012 R2:

System.Net.Http.WinHttpException: A security error occurred

I'm using the following code in my .NET Core api controller to try and obtain the access token:

var body = new Dictionary<string, string>();
        body.Add("grant_type", "authorization_code");
        body.Add("client_id", "xxx");
        body.Add("redirect_uri", "xxx");
        body.Add("code", "xxx");

        var accessTokenResponse = await client.PostAsync("xxx/adfs/oauth2/token", new FormUrlEncodedContent(body));

Where the "xxx" are the parameters I used to request the auth code, so I'm pretty sure these are correct.

Quite new to this and I'm not sure what exactly is going wrong. Is this a cors related error?

Upvotes: 1

Views: 2216

Answers (1)

user5661230
user5661230

Reputation:

This error was caused by not having the right certificate installed. Installing the certificate on the server solved the problem.

Upvotes: 1

Related Questions