OAuth2\Service::getAccessToken PHP Method

getAccessToken() public method

get access token of from service, has to be called after successful authorization
public getAccessToken ( string $code = null )
$code string optional, if no code given method tries to get it out of $_GET
    public function getAccessToken($code = null)
    {
        if (!$code) {
            if (!isset($_GET['code'])) {
                throw new Exception('could not retrieve code out of callback request and no code given');
            }
            $code = $_GET['code'];
        }
        $parameters = array('grant_type' => 'authorization_code', 'type' => 'web_server', 'client_id' => $this->_client->getClientKey(), 'client_secret' => $this->_client->getClientSecret(), 'redirect_uri' => $this->_client->getCallbackUrl(), 'code' => $code);
        if ($this->_scope) {
            $parameters['scope'] = $this->_scope;
        }
        $http = new HttpClient($this->_configuration->getAccessTokenEndpoint(), 'POST', http_build_query($parameters));
        //$http->setDebug(true);
        $http->execute();
        $this->_parseAccessTokenResponse($http);
    }