authenticate() 공개 메소드

public authenticate ( $code )
예제 #1
0
 /**
  * {@inheritdoc}
  */
 function loginFinish()
 {
     $error = array_key_exists('error', $_REQUEST) ? $_REQUEST['error'] : "";
     // check for errors
     if ($error) {
         throw new Exception("Authentication failed! {$this->providerId} returned an error: {$error}", 5);
     }
     // try to authenticate user
     $code = array_key_exists('code', $_REQUEST) ? $_REQUEST['code'] : "";
     try {
         $this->api->authenticate($code);
     } catch (Exception $e) {
         throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e}", 6);
     }
     // check if authenticated
     if (!$this->api->access_token) {
         throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
     }
     // store tokens
     $this->token("access_token", $this->api->access_token);
     $this->token("refresh_token", $this->api->refresh_token);
     $this->token("expires_in", $this->api->access_token_expires_in);
     $this->token("expires_at", $this->api->access_token_expires_at);
     // set user connected locally
     $this->setUserConnected();
 }