0

In Postman I am able to generate the Bearer token using

  1. Callback URL
  2. Auth URL
  3. Client ID

How do I do the same using C# code?

This is the code I am running but the response body does not have the bearer token.

var client = new RestClient("AuthURL"); 
var requestToken = new RestRequest(Method.POST); 
requestToken.AddHeader("cache-control", "no-cache"); 
requestToken.AddHeader("content-type", "application/x-www-form-urlencoded"); 
requestToken.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&client_id=123", ParameterType.RequestBody); 
IRestResponse response = client.Execute(requestToken);

string res = response.Content;

1 Answers1

0

where is your username and password?

var client = new RestClient("http://example.com");
client.Authenticator = new HttpBasicAuthenticator(userName, password);

var request = new RestRequest("resource", Method.GET);
client.Execute(request);

might be a duplicate of this question RestSharp HttpBasicAuthentication - example

Fractal
  • 1,748
  • 5
  • 26
  • 46