2016-05-07 4 views
1

ich diese Störung erhalte beim Versuch, mit Google in Codeigniter einzuloggen nur auf dem ersten VersuchAusnahme: Erforderliche Option nicht bestanden: access_token

Fatal error: Uncaught exception 'Exception' with message ' in ..../application/libraries/OAuth2/Token/Access.php on line 44 
Exception: Required option not passed: access_token in ..../application/libraries/OAuth2/Token/Access.php on line 44 

enter image description here

+0

Vielleicht könnten Sie ein Beispiel für Ihren Code geben? [Hier] (https://developers.google.com/identity/protocols/OAuth2WebServer#handlingresponse) können Sie weitere Informationen darüber finden, wie Sie einen AccessStoken in Ihrer App bekommen können. –

Antwort

0

Wenn Sie oauth2 verwenden, zur Bibliothek/oauth2 /provider.php gibt es eine Funktion namens access, in diesem Fall: POST, mach es, was ich unten gezeigt habe.

 case 'POST': 

      $ci = get_instance(); 

      /*$ci->load->spark('curl/1.2.1'); 

      $ci->curl 
       ->create($url) 
       ->post($params, array('failonerror' => false)); 

      $response = $ci->curl->execute();*/ 

Glücklich Codierung

+0

Ohne zu sehen, Bibliotheken/oauth2/provider.php, welche ist Linie 182? Der mit ''failonerror' => false'? Bitte [bearbeiten] Sie Ihren Beitrag und fügen Sie einen Kommentar in die richtige Zeile ein. Zeilennummern allein sind keine gute Referenz, da sie sich bei neueren Versionen des Codes ändern könnten. Vielen Dank! –

2

Versuchen Sie, Ihre access.php Datei zu ändern und __construct Methode ändern.

public function __construct(array $options = null) 
{ 
    echo "<pre>"; 
    $new_options = array(); 
    foreach($options as $key => $value) 
    { 
     $new_options = json_decode($key,true); 
    } 

    if (! isset($new_options['access_token'])) 
    { 
     throw new Exception('Required option not passed: access_token'.PHP_EOL.print_r($new_options, true)); 
    } 

    // if (! isset($options['expires_in']) and ! isset($options['expires'])) 
    // { 
    // throw new Exception('We do not know when this access_token will expire'); 
    // } 


    $this->access_token = $new_options['access_token']; 

    // Some providers (not many) give the uid here, so lets take it 
    isset($new_options['uid']) and $this->uid = $new_options['uid']; 

    //Vkontakte uses user_id instead of uid 
    isset($new_options['user_id']) and $this->uid = $new_options['user_id']; 

    //Mailru uses x_mailru_vid instead of uid 
    isset($new_options['x_mailru_vid']) and $this->uid = $new_options['x_mailru_vid']; 

    // We need to know when the token expires, add num. seconds to current time 
    isset($new_options['expires_in']) and $this->expires = time() + ((int) $new_options['expires_in']); 

    // Facebook is just being a spec ignoring jerk 
    isset($new_options['expires']) and $this->expires = time() + ((int) $new_options['expires']); 

    // Grab a refresh token so we can update access tokens when they expires 
    isset($new_options['refresh_token']) and $this->refresh_token = $new_options['refresh_token']; 
} 
+0

Diese Lösung funktioniert gut für Facebook, gibt aber einen Fehler für Google Login –

Verwandte Themen