AnsweredAssumed Answered

Invalid code error on fetching oauth2 token

Question asked by pallavi dhanuka on Aug 22, 2016
Latest reply on Aug 24, 2016 by Danny Wahl

I am using  PHP CURL to get the auth token from canvas.

 

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $canvasUri.'/login/oauth2/token');

curl_setopt($ch, CURLOPT_POST, TRUE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$post_params = array("client_id"=>$clientId,"client_secret"=>$secret,"code"=>$code,

                       "grant_type" => 'authorization_code',

                       'redirect_uri' => $redirectUri);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);

 

curl_setopt($ch, CURLOPT_HTTPHEADER, array(

    'Accept: application/json'

));

$response = curl_exec($ch);

 

 

On authorizing the app from canvas, when I send the above POST request I get the below error:{"error":"invalid_request","error_description":"client does not have access to specified account","message":"invalid code"}

Tried several alternatives, used Postman ( a REST client to test), still the same error.
It would be really great if any help provided.
Thanks!

Outcomes