Cannot GET access tokens using Authorization code in .net console app, which work in POST MAN
Hi All, I like to seek help on a issue i am facing when i try to authenticate into BOX.
Step 1: i used https://account.box.com/api/oauth2/authorize?response_type=code&client_id="my id"
to get Auth code.
Step 2: i tried to get Access & refresh tokens using postman it worked fine.
Step 3: Now i tried to automate process of getting Access and refresh tokens using .net code.
string param = string.Format("grant_type=authorization_code&code={0}&client_id={1}&client_secret={2}", "mycode", "myid", "mysecret");
var client = new RestClient("https://pfizer.app.box.com/oauth2/token/");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", param, ParameterType.RequestBody);
var response = client.Execute(request);
var json = JObject.Parse(response.Content);
Console.WriteLine(json);
I always get Bad request ,
{ "error": "invalid_grant", "error_description": "The authorization code has expired" }
I am not using auth code 2 times anywhere, even fresh token does not give any response.
Reference article:
Please help.
Thanks.
サインインしてコメントを残してください。
コメント
3件のコメント