Migration from JWT to Server-to-Server OAuth utilizing C# .Net Framework 4.7 Console App

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();

  • The Authorization header value should be approximately "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(ClientID + ":" + ClientSecret)) (not tested, but estimated from a different technology stack).
  • Server-to-Server OAuth should be using the grant_type value account_credentials.
  • Make sure the account_id value is set to the Account ID from your application credentials, not Client ID (as implied by your variable name).
2 Likes

Thanks Christopher! I’ll test with those alterations.

I receive a token now, however, had to use client_credentials within the rest api.
account_credentials returns all null. account_credentials does however, work in Postman.

Hi @cmcdaniel ,

Glad this is resolved. For future reference, here’s our Postman workspace with Server-to-Server OAuth set up: Postman

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.