Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
Created September 5, 2012 15:23
Show Gist options
  • Save xcommerce-gists/3638340 to your computer and use it in GitHub Desktop.
Save xcommerce-gists/3638340 to your computer and use it in GitHub Desktop.
PayPalAccessOpenIDConnect.PHP
/**
* 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