Beispiel #1
0
 /**
  * Verify the login result and do whatever is needed to access the user data from this provider.
  * @return bool
  */
 public function verify()
 {
     // create token
     $request_token = OAuth_Token::factory('request', array('token' => Session::instance()->get('oauth_token'), 'secret' => Session::instance()->get('oauth_token_secret')));
     // Store the verifier in the token
     $verifier = Arr::get($_REQUEST, 'oauth_verifier');
     if (empty($verifier)) {
         return false;
     }
     $request_token->verifier($verifier);
     // Exchange the request token for an access token
     $access_token = $this->provider->access_token($this->consumer, $request_token);
     if ($access_token and $access_token->name === 'access') {
         $request = OAuth_Request::factory('resource', 'GET', 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,email-address)?format=json', array('oauth_consumer_key' => $this->consumer->key, 'oauth_signature_method' => "HMAC-SHA1", 'oauth_token' => $access_token->token));
         // Sign the request using only the consumer, no token is available yet
         $request->sign(new OAuth_Signature_HMAC_SHA1(), $this->consumer, $access_token);
         // decode and store data
         $data = json_decode($request->execute(), true);
         $this->uid = $data['id'];
         $this->data = $data;
         return true;
     } else {
         return false;
     }
 }
Beispiel #2
0
 /**
  * Verify the login result and do whatever is needed to access the user data from this provider.
  * @return bool
  */
 public function verify()
 {
     // create token
     $request_token = OAuth_Token::factory('request', array('token' => Session::instance()->get('oauth_token'), 'secret' => Session::instance()->get('oauth_token_secret')));
     // Store the verifier in the token
     $request_token->verifier($_REQUEST['oauth_verifier']);
     // Exchange the request token for an access token
     $access_token = $this->provider->access_token($this->consumer, $request_token);
     if ($access_token and $access_token->name === 'access') {
         // @link  http://dev.twitter.com/doc/get/account/verify_credentials
         $request = OAuth_Request::factory('resource', 'GET', 'http://api.twitter.com/1/account/verify_credentials.json', array('oauth_consumer_key' => $this->consumer->key, 'oauth_token' => $access_token->token));
         // Sign the request using only the consumer, no token is available yet
         $request->sign(new OAuth_Signature_HMAC_SHA1(), $this->consumer, $access_token);
         // decode and store data
         $data = json_decode($request->execute(), true);
         $this->uid = $data['id'];
         $this->data = $data;
         return true;
     } else {
         return false;
     }
 }
Beispiel #3
0
 /**
  * Exchange the request token for an access token.
  *
  *     $token = $provider->access_token($consumer, $token);
  *
  * @param   OAuth_Consumer       consumer
  * @param   OAuth_Token_Request  token
  * @param   array                additional request parameters
  * @return  OAuth_Token_Access
  */
 public function access_token(OAuth_Consumer $consumer, OAuth_Token_Request $token, array $params = NULL)
 {
     // Create a new GET request for a request token with the required parameters
     $request = OAuth_Request::factory('access', 'GET', $this->url_access_token(), array('oauth_consumer_key' => $consumer->key, 'oauth_token' => $token->token, 'oauth_verifier' => $token->verifier));
     if ($params) {
         // Load user parameters
         $request->params($params);
     }
     // Sign the request using only the consumer, no token is available yet
     $request->sign($this->signature, $consumer, $token);
     // Create a response from the request
     $response = $request->execute();
     // Store this token somewhere useful
     return OAuth_Token::factory('access', array('token' => $response->param('oauth_token'), 'secret' => $response->param('oauth_token_secret')));
 }