private function moveToAuth(AbstractProvider $provider) { $authorizationUrl = $provider->getAuthorizationUrl(); $_SESSION['oauth2state'] = $provider->getState(); header('Location: ' . $authorizationUrl); exit; }
protected function makeRegistrationRequest(AbstractProvider $provider, AccessToken $accessToken) : RegistrationRequest { /** @var GoogleUser $resourceOwner */ $resourceOwner = $provider->getResourceOwner($accessToken); $email = $resourceOwner->getEmail(); $providerAccountId = (string) $resourceOwner->getId(); return new RegistrationRequest('google', $providerAccountId, $email, $resourceOwner); }
public function testSetRedirectHandler() { $this->testFunction = false; $callback = function ($url) { $this->testFunction = $url; }; $this->provider->setRedirectHandler($callback); $this->provider->authorize('http://test.url/'); $this->assertNotFalse($this->testFunction); }
/** * @param AbstractProvider $provider * @param AccessToken $token * @param string $providerName * @param SS_HTTPRequest $request */ public function afterGetAccessToken(AbstractProvider $provider, AccessToken $token, $providerName, SS_HTTPRequest $request) { $user = $provider->getResourceOwner($token); try { $member = $this->memberFromResourceOwner($user, $providerName); $this->owner->setMember($member); } catch (TokenlessUserExistsException $e) { return Security::permissionFailure($this->owner, $e->getMessage()); } $result = $member->canLogIn(); if (!$result->valid()) { return Security::permissionFailure($this->owner, $result->message()); } $member->logIn(); }
/** * Constructs an OAuth 2.0 service provider. * * @param array $options An array of options to set on this provider. * Options include `clientId`, `clientSecret`, `redirectUri`, and `state`. * Individual providers may introduce more options, as needed. * @param array $collaborators An array of collaborators that may be used to * override this provider's default behavior. Collaborators include * `grantFactory`, `requestFactory`, `httpClient`, and `randomFactory`. * Individual providers may introduce more collaborators, as needed. */ public function __construct(array $options = [], array $collaborators = []) { parent::__construct($options, $collaborators); if ($this->token) { $this->token = new ModulbankAccessToken(['accessToken' => $this->token]); } }
/** * Prepares an parsed access token response for a grant. * * Custom mapping of expiration, etc should be done here. Always call the * parent method when overloading this method. * * @param mixed $result * @return array */ protected function prepareAccessTokenResponse(array $result) { if (isset($result['data'])) { $result = $result['data']; } return parent::prepareAccessTokenResponse($result); }
/** * Provider constructor. * @param array $options */ public function __construct(array $options = array()) { parent::__construct($options); if (isset($options['sandbox']) && $options['sandbox']) { $this->baseURL = 'https://api.sandbox.freeagent.com/v2/'; } }
/** * Gitlab constructor. * * @param array $options * @param array $collaborators */ public function __construct(array $options, array $collaborators = []) { if (isset($options['domain'])) { $this->domain = $options['domain']; } parent::__construct($options, $collaborators); }
/** * Constructs an OAuth 2.0 service provider. * * @param array $options An array of options to set on this provider. * Options include `clientId`, `clientSecret`, `redirectUri`, and `state`. * Individual providers may introduce more options, as needed. * @param array $collaborators An array of collaborators that may be used to * override this provider's default behavior. Collaborators include * `grantFactory`, `requestFactory`, `httpClient`, and `randomFactory`. * Individual providers may introduce more collaborators, as needed. */ public function __construct(array $options = [], array $collaborators = []) { parent::__construct($options, $collaborators); if (empty($this->subdomain)) { throw new Exception\ProviderConfigurationException('No subdomain has been configured for this Zendesk provider; it has to have a subdomain.'); } }
public function __construct($options = []) { if (!array_has($options, 'redirectUri')) { $options['redirectUri'] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; } parent::__construct($options); }
public function __construct($options = []) { if (empty($options['domainPrefix'])) { throw new \RuntimeException('Vend provider requires a "domainPrefix" option'); } parent::__construct($options); }
public function getAccessToken($grant, array $options = []) { if ($this->authWithResource) { $options['resource'] = $this->resource ? $this->resource : $this->urlAPI; } return parent::getAccessToken($grant, $options); }
/** * @param array $options * @param array $collaborators */ public function __construct($options = [], array $collaborators = []) { parent::__construct($options); if (isset($options['devMode'])) { $this->setDevMode($options['devMode']); } }
/** * Constructs an OAuth 2.0 service provider. * * @param array $options An array of options to set on this provider. * Options include `clientId`, `clientSecret`, `redirectUri`, and `state`. * Individual providers may introduce more options, as needed. * @param array $collaborators An array of collaborators that may be used to * override this provider's default behavior. Collaborators include * `grantFactory`, `requestFactory`, `httpClient`, and `randomFactory`. * Individual providers may introduce more collaborators, as needed. */ public function __construct(array $options = [], array $collaborators = []) { if (isset($options['encryptionKeyPath'])) { $this->setEncryptionKeyPath($options['encryptionKeyPath']); unset($options['encryptionKeyPath']); } parent::__construct($options, $collaborators); }
/** * {@inheritdoc} */ public function __construct(array $options = [], array $collaborators = []) { if (!empty($options['domain'])) { $this->domain = $options['domain']; // for custom environments } parent::__construct($options, $collaborators); }
public function getAuthorizationUrl($options = []) { $url = parent::getAuthorizationUrl($options); if ($this->testMode) { $url .= '&sandbox=true'; } return $url; }
protected function getAuthorizationParameters(array $options) { $parameters = parent::getAuthorizationParameters($options); if (isset($options["type"])) { $parameters["type"] = $options["type"]; } return $parameters; }
public function __construct(array $options = [], array $collaborators = []) { parent::__construct($options, $collaborators); if (!isset($options['account'])) { throw new HumanClientException('Account must be supllied'); } $this->changeDomainUrl($options['account']); }
public function __construct($options = array()) { if (empty($options['rootUrl'])) { throw new UnexpectedValueException('Missing rootUrl configuration'); } parent::__construct($options); $this->_domain = rtrim($options['rootUrl'], '/'); }
public function getAuthorizationUrl($options = array()) { $url = parent::getAuthorizationUrl($options); if (!empty($this->hostedDomain)) { $url .= '&' . $this->httpBuildQuery(['hd' => $this->hostedDomain]); } return $url; }
protected function createAccessToken(array $response, \League\OAuth2\Client\Grant\AbstractGrant $grant) { $token = parent::createAccessToken($response, $grant); if (!empty($response['email'])) { $token->email = $response['email']; } return $token; }
public function __construct(array $options = [], array $collaborators = [], $mode = null) { $this->assertRequiredOptions($options); foreach ($options as $key => $value) { $this->{$key} = $value; } $this->mode = $mode; parent::__construct($options, $collaborators); }
protected function getAuthorizationParameters(array $options) { if (is_array($this->scope)) { $separator = $this->getScopeSeparator(); $this->scope = implode($separator, $this->scope); } $params = array_merge(parent::getAuthorizationParameters($options), array_filter(['hd' => $this->hostedDomain, 'access_type' => $this->accessType, 'scope' => $this->scope, 'authuser' => '-1'])); return $params; }
/** * Constructs an OAuth 2.0 service provider. * * @param array $options An array of options to set on this provider. * Options include `clientId`, `clientSecret`, `redirectUri`, `state`, `apiVersion`. * Individual providers may introduce more options, as needed. * @param array $collaborators An array of collaborators that may be used to * override this provider's default behavior. Collaborators include * `grantFactory`, `requestFactory`, `httpClient`, and `randomFactory`. * Individual providers may introduce more collaborators, as needed. */ public function __construct(array $options = [], array $collaborators = []) { parent::__construct($options, $collaborators); foreach ($options as $option => $value) { if (property_exists($this, $option)) { $this->{$option} = $value; } } }
/** * @param array $options * @param array $collaborators * * @throws \InvalidArgumentException */ public function __construct($options = [], array $collaborators = []) { parent::__construct($options, $collaborators); if (empty($options['storeName'])) { $message = 'The "storeName" option not set. Please set Store Name.'; throw new \InvalidArgumentException($message); } $this->storeName = $options['storeName']; }
public function __construct($options = array()) { parent::__construct($options); if (isset($options['dhis2ServerUri'])) { $this->dhis2ServerUri = $options['dhis2ServerUri']; } else { throw new \Exception("dhis2ServerUri not set. This is the DHIS Server URL", 1); } }
public function getAuthorizationUrl(array $options = []) { $url = parent::getAuthorizationUrl($options); $params = array_filter(['hd' => $this->hostedDomain, 'access_type' => $this->accessType]); if ($params) { $url .= '&' . $this->httpBuildQuery($params); } return $url; }
public function getHeaders($token = NULL, $username = NULL, $password = NULL) { $headers = parent::getHeaders($token); $headers['x-myobapi-key'] = $this->clientId; if ($username) { $headers['x-myobapi-cftoken'] = base64_encode($username . ":" . $password); } return $headers; }
/** * @param $grant * @param array $params */ public function getAccessToken($grant = 'authorization_code', array $params = []) { if (isset($params['refresh_token'])) { throw new LightspeedProviderException('Lightspeed does not support token refreshing.'); } return parent::getAccessToken($grant, $params); }
/** * {@inheritdoc} */ public function authenticate(RequestInterface $request) { // TODO: add error handling // TODO: support other grant types? $accessToken = $this->provider->getAccessToken('client_credentials'); return $request->withHeader('Authorization', 'Bearer ' . $accessToken); }