Created
September 5, 2012 15:23
-
-
Save xcommerce-gists/3638340 to your computer and use it in GitHub Desktop.
PayPalAccessOpenIDConnect.PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get Access Token | |
* | |
* After the user is forwarded back to the application callback (defined in | |
* the application at devportal.x.com) and the code parameter is available on | |
* the query string, exchange the code parameter for an access token. | |
* | |
*/ | |
public function get_access_token(){ | |
$code = $_GET['code']; | |
$postvals = sprintf("client_id=%s&client_secret=%s&grant_type=authorization_code&code=%s", | |
$this->key, | |
$this->secret, | |
$code, | |
urlencode($this->callback_url)); | |
$token = json_decode($this->run_curl(ACCESS_TOKEN_ENDPOINT, "POST", $postvals)); | |
$this->access_token = $token->access_token; | |
$this->refresh_token = $token->refresh_token; | |
$this->id_token = $token->id_token; | |
return $token; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment