Description:
We’re coding oAuth Server-to-Server connection to receive a token back. I have setup my header and body as follows in the code sample provided. I’m using the developer setup here: Server-to-Server OAuth
Please let me know exactly what goes into the head and body and if there is a better resource for this in a C# framework 4.7 console application.
Error:
400 Bad Request
Code to reproduce:
//HEADERS
var headers = new Dictionary<string, string>
{
{ “Host”, “zoom.us”},
{ “Authorization”, string.Format(“Basic clientId: {0}”, Convert.ToBase64String(Encoding.ASCII.GetBytes(ClientSecret))) },
};
//BODY
FormUrlEncodedContent body = new FormUrlEncodedContent(
new KeyValuePair<string, string>
{
new KeyValuePair<string, string>(“grant_type”,“authorization_code”),
new KeyValuePair<string, string>(“account_id”, ClientId)
}
);
//RESPONSE
var httpclient = new HttpClient();
var response = Task.Run(() => httpclient.PostAsync( TokenEndpoint, body )).GetAwaiter().GetResult();