authorizationEndpoint)) { throw new InvalidServiceConfigurationException('No AuthorizationEndpoint set'); } return $this->authorizationEndpoint; } /** * Set the authorization endpoint. * * has to be called before using the service * * @param $url */ public function setAuthorizationEndpoint($url) { $this->authorizationEndpoint = new Uri($url); } /** * {@inheritdoc} */ public function getAccessTokenEndpoint() { if(is_null($this->accessTokenEndpoint)) { throw new InvalidServiceConfigurationException('No AccessTokenEndpoint set'); } return $this->accessTokenEndpoint; } /** * Set the access token endpoint. * * has to be called before using the service * * @param $url */ public function setAccessTokenEndpoint($url) { $this->accessTokenEndpoint = new Uri($url); } /** * {@inheritdoc} */ protected function getAuthorizationMethod() { return static::AUTHORIZATION_METHOD_QUERY_STRING; } /** * {@inheritdoc} */ protected function parseAccessTokenResponse($responseBody) { $data = json_decode($responseBody, true); if (null === $data || !is_array($data)) { throw new TokenResponseException('Unable to parse response.'); } elseif (isset($data['error'])) { throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); } $token = new StdOAuth2Token(); $token->setAccessToken($data['access_token']); if (isset($data['expires'])) { $token->setLifeTime($data['expires']); } if (isset($data['refresh_token'])) { $token->setRefreshToken($data['refresh_token']); unset($data['refresh_token']); } unset($data['access_token']); unset($data['expires']); $token->setExtraParams($data); return $token; } }