示例#1
0
 public function callback()
 {
     // Create an consumer from the config
     $this->consumer = \OAuth\Consumer::forge($this->config);
     // Load the provider
     $this->provider = \OAuth\Provider::forge($this->provider);
     if ($token = Cookie::get('oauth_token')) {
         // Get the token from storage
         $this->token = unserialize(base64_decode($token));
     }
     if ($this->token and $this->token->access_token !== Input::param('oauth_token')) {
         // Delete the token, it is not valid
         Cookie::delete('oauth_token');
         // Send the user back to the beginning
         exit('invalid token after coming back to site');
     }
     // Get the verifier
     $verifier = Input::param('oauth_verifier');
     // Store the verifier in the token
     $this->token->verifier($verifier);
     // Exchange the request token for an access token
     return $this->provider->access_token($this->consumer, $this->token);
 }