These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

eve-sso-auth: no character ID returned

Author
Tommaxx
Caldari Provisions
Caldari State
#1 - 2017-02-23 09:15:05 UTC  |  Edited by: Tommaxx
Hello,

i'm working on SSO with eve-sso-auth by fuzzysteve.

Error log tells "no character ID returned":

AH01071: Got error 'PHP message: No character ID returned\n', referer: https://login.eveonline.com/oauth/authorize?response_type=code&redirect_uri=https%3A%2F%2Fwho.drasy.de%2Fdevauthcallback.php&client_id=75037c3ab85e4e998f229d8e2d6c93c1&scope=&state=58aea04802173


devauthcallback.php

I was looking for solutions at this file from line 49 to 62 but did not sort it out. Maybe some problem with CURL?

o7
Tommaxx

Edit:
Updated CURL error reporting with curl_setopt($ch,CURLOPT_FAILONERROR,true); and now get 400 error:
 AH01071: Got error 'PHP message: The requested URL returned error: 400 Bad Request\n', referer: https://login.eveonline.com/oauth/authorize?response_type=code&redirect_uri=https%3A%2F%2Fwho.drasy.de%2Fdevauthcallback.php&client_id=75037c3ab85e4e998f229d8e2d6c93c1&scope=&state=58aea4d9d35c6


Edit 2:
Did some further testing, CURL seems to work fine now (no curl error given), this is the error i get (i assume it's sent by ccp server?):
{"error":"invalid_client","error_description":"Unknown client"}


As you can see, this becomes more a progress journal than a discussion... anyway, solving the invalid client error lead to this one:
{"error":"invalid_request","error_description":"Authorization code not found"}


and this error was because there was too much time between testing and logging in. now it works.

If some newbee has issues with very basic sso stuff, contact me :-)
Snitch Ashor
Republic Military School
Minmatar Republic
#2 - 2017-03-07 08:56:12 UTC
This is a part of my sso class that might help you. Its based on Steves script. Once I got the code i use this to get a token:

    
public function setCode($code) {
        $this->code = $code;

                $url = 'https://login.eveonline.com/oauth/token';
                $header = 'Authorization: Basic '.base64_encode($this->config['evesso_clientid'].':'.$this->config['evesso_code']);
                $fields_string = '';
                $fields = array(
                    'grant_type' => 'authorization_code',
                    'code' => $code,
                    );
                foreach ($fields as $key => $value) {
                    $fields_string .= $key.'='.$value.'&';
                }
                rtrim($fields_string, '&');
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_USERAGENT, self::$userAgent);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
                curl_setopt($ch, CURLOPT_POST, count($fields));
                curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                $result = curl_exec($ch);
                if ($result === false) {
                    $this->error = true;
                    $this->message = (curl_error($ch));
                }
                curl_close($ch);
                if (!$this->error){
                    $response = json_decode($result);
                    $this->accessToken = $response->access_token;
                    $this->expires = (strtotime("now")+1000);
                    $this->refreshToken = $response->refresh_token;
                    $result = $this->verify();
                    return $result;
                } else {
                    return false;
                }
    }


In the last step i call verify, which then gives you characterid and name:


public function verify() {
    if (!isset($this->accessToken)) {
                    $this->error = true;
                    $this->message = "No Acess Token to verify.";
                    return false;
        } else {
                    $verify_url = 'https://login.eveonline.com/oauth/verify';
                    $ch = curl_init();
                    $header = 'Authorization: Bearer '.$this->accessToken;
                    curl_setopt($ch, CURLOPT_URL, $verify_url);
                    curl_setopt($ch, CURLOPT_USERAGENT, self::$userAgent);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                    $result = curl_exec($ch);
                    if ($result === false) {
                        $this->error = true;
                        $this->message = (curl_error($ch));
                    }
                    curl_close($ch);
                    if ($this->error) {
            return false;
            }
                        $response = json_decode($result);
                        if (isset($response->error)) {
                            $this->error = true;
                            $this->message = $response->error;
                            return false;
                        }
                        if (!isset($response->CharacterID)) {
                            $this->error = true;
                            $this->message = "Failed to get character ID.";
                            return false;
                        }
                        $this->characterID = $response->CharacterID;
                        $this->characterName = $response->CharacterName;
                        $this->scopes = explode(' ', $response->Scopes);
                        if ($this->scopes == null || $this->scopes == '') {
                            $this->error = true;
                            $this->message = 'Scopes missing.';
                            return false;
                        }
                        $this->ownerHash = $response->CharacterOwnerHash;
                }
        return true;
    }


You might strip it down quite a bit e.g. when not using scopes but i hope it gives you an idea.