/** * Get access token by user authorization code * @param string $code user authorization code * @return Error|Token token or error instance */ public function authorize($code) { $Request = $this->getRequest(self::ENDPOINT_ACCESS_TOKEN_REQUEST); $Request->addPostField('code', $code)->addPostField('client_id', $this->getClientId())->addPostField('client_secret', $this->getClientSecret())->addPostField('redirect_uri', $this->getRedirectUri()); return ResponseFactory::createResponse($Request->send()); }
/** * Authorize method * @return Token|Error token or error instance */ public function authorize() { $Request = $this->getRequest(self::ENDPOINT_ACCESS_TOKEN_REQUEST); $Request->addPostField('client_id', $this->getClientId())->addPostField('client_secret', $this->getClientSecret())->addPostField('grant_type', self::GRANT_TYPE_CLIENT_CREDENTIALS); return ResponseFactory::createResponse($Request->send()); }