The response from this call will be a 301, resulting in a redirect for the user to authenticate. This is intended only as an example of what the URI could look like.
var contentType = "application/json";
var uri = "https://signin.test.purefarming.com/auth/realms/moa/protocol/openid-connect/token";
var request = new {
grant_type = "authorization_code",
client_id = "myclient",
code = "<<returned code>>",
redirect_uri = "http://localhost/callback",
code_verifier = "xyz098"
};
var requestJson = JsonConvert.SerializeObject(request);
var content = new StringContent(requestJson, Encoding.UTF8, contentType);
var client = new HttpClient();
var response = await client.PostAsync(uri, content);
var contentType = "application/json";
var uri = "https://signin.test.purefarming.com/auth/realms/moa/protocol/openid-connect/token";
var request = new {
grant_type = "client_credentials",
client_id = "myclient",
client_secret = "mysecret",
scope = "openid profile offline_access"
};
var requestJson = JsonConvert.SerializeObject(request);
var content = new StringContent(requestJson, Encoding.UTF8, contentType);
var client = new HttpClient();
var response = await client.PostAsync(uri, content);