Created
April 8, 2013 07:52
-
-
Save anonymous/5335009 to your computer and use it in GitHub Desktop.
Request OAuth access token
--- *@param string $code* OAuth code we got from service
*@return* string Token, or null if we didn't obtain a proper token
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
/** | |
* Request OAuth access token | |
* | |
* @param string $code OAuth code we got from service | |
* @return string Token, or null if we didn't obtain a proper token | |
*/ | |
protected function _requestToken($code) | |
{ | |
$config = $this->_config->oauth; | |
$client = new \Zend_Http_Client("http://accounts.tunehog.com/oauth/token"); | |
$client->setParameterPost([ | |
'grant_type' => 'authorization_code', | |
'client_id' => $config->client_id, | |
'client_secret' => $config->client_secret, | |
'code' => $code, | |
]); | |
if ($response = $this->_helper->http->request($client, 'POST')) { | |
$response = \Zend_Json::decode($response->getBody(), \Zend_Json::TYPE_OBJECT); | |
if (isset($response->access_token)) { | |
return $response->access_token; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment