Getting started on the PHP SDK

Getting started on the PHP SDK

I was attempting to authorize the test app, but every time I send the cURL to get my initial refresh token.

I keep getting "error":"invalid_code".

I have followed all of the documentation.

I found the three reasons for this in the documentation but the only one that could apply does not make any sense.

I am literally making the request within 5 seconds of generating the auth code from the API Console.

Timeout/Auth Code Expiration is not the reason this is not working.

I am using the self-client to generate the auth code with Creator Scopes.

This is the base URL I grabbed from the documentation.

https://<base_accounts_url>/oauth/v2/token?grant_type=authorization_code&client_id=<client_id>&client_secret=<client_secret>&redirect_uri=<redirect_uri>&code=<authorization_code>

function generate_refresh_token($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, 1);
    if(curl_exec($ch) === false) {
        $err = 'Curl error: ' . curl_error($ch);
        print $err;
        curl_close($ch);
    } else {
        $response = curl_exec($ch);
        echo '<br><br>';
        print $response.'Operation completed without any errors';
        print_r($response);
        curl_close($ch);
    }
  }

Any help with this is greatly appreciated.