ccpgames / sso-issues

Please file issues with the CCP SSO (login.eveonline.com) here.
17 stars 1 forks source link

Unable to request Token - Grant type is not supported. #53

Closed bab2k84 closed 5 years ago

bab2k84 commented 5 years ago

Bug

I'm unable to request a token from https://login.eveonline.com/v2/oauth/token I recieve the below response.

{"error":"invalid_grant","error_description":"Grant type is not supported."}

I'm using PHP to make a CURL request to the server but can't seem to work out where the error is in my code - See Below

$headers = [ 'Authorization: Basic ' . base64_encode(self::$credentials['clientId'] . ':' . self::$credentials['secretKey']), 'Content-Type: application/x-www-form-urlencoded', ];

    // Seems like CCP does not mind JSON in the body. Yay.
    $fields = json_encode([
        'grant_type' => 'authorization_code',
        'code'       => $code,
    ]);

    // Start a cURL session
    $ch = curl_init('https://login.eveonline.com/v2/oauth/token');
    curl_setopt_array($ch, [
            CURLOPT_URL             => 'https://login.eveonline.com/v2/oauth/token',
            CURLOPT_POST            => true,
            CURLOPT_POSTFIELDS      => '?grant_type=authorization_code&code='.$code,
            CURLOPT_HTTPHEADER      => $headers,
            CURLOPT_RETURNTRANSFER  => true,
        ]
    );

    $result = curl_exec($ch);

Any help would be greatly appreciated Thanks

BaldvinTh commented 5 years ago

Please remove the question mark in post fields. Example: CURLOPT_POSTFIELDS => "grant_type=authorization_code&code=".$code,