本文整理汇总了PHP中League\OAuth2\Client\Provider\AbstractProvider::getAuthorizationUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractProvider::getAuthorizationUrl方法的具体用法?PHP AbstractProvider::getAuthorizationUrl怎么用?PHP AbstractProvider::getAuthorizationUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\OAuth2\Client\Provider\AbstractProvider
的用法示例。
在下文中一共展示了AbstractProvider::getAuthorizationUrl方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
/**
* Creates a RedirectResponse that will send the user to the
* OAuth2 server (e.g. send them to Facebook).
*
* @param array $scopes The scopes you want (leave empty to use default)
* @return RedirectResponse
*/
public function redirect(array $scopes = [])
{
$options = [];
if (!empty($scopes)) {
$options['scope'] = $scopes;
}
$url = $this->provider->getAuthorizationUrl($options);
// set the state (unless we're stateless)
if (!$this->isStateless) {
$this->getSession()->set(self::OAUTH2_SESSION_STATE_KEY, $this->provider->getState());
}
return new RedirectResponse($url);
}
示例2: moveToAuth
private function moveToAuth(AbstractProvider $provider)
{
$authorizationUrl = $provider->getAuthorizationUrl();
$_SESSION['oauth2state'] = $provider->getState();
header('Location: ' . $authorizationUrl);
exit;
}
示例3: getAuthorizationUrl
public function getAuthorizationUrl($options = [])
{
$url = parent::getAuthorizationUrl($options);
if ($this->testMode) {
$url .= '&sandbox=true';
}
return $url;
}
示例4: getAuthorizationUrl
public function getAuthorizationUrl($options = array())
{
$url = parent::getAuthorizationUrl($options);
if (!empty($this->hostedDomain)) {
$url .= '&' . $this->httpBuildQuery(['hd' => $this->hostedDomain]);
}
return $url;
}
示例5: getAuthorizationUrl
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;
}
示例6: getAuthorizationUrl
public function getAuthorizationUrl(array $options = [])
{
// this one is a tough one, it's impossible to provide the scopes and state anywhere else
// than in this options array,
$options['state'] = $this->getState();
if (!empty($this->scopes)) {
$options['scope'] = $this->scopes;
}
return parent::getAuthorizationUrl($options);
}
示例7: handle
/**
* @param Request $request
* @return \Psr\Http\Message\ResponseInterface|RedirectResponse
*/
public function handle(Request $request)
{
$redirectUri = (string) $request->getAttribute('originalUri', $request->getUri())->withQuery('');
$this->provider = $this->getProvider($redirectUri);
$session = $request->getAttribute('session');
$queryParams = $request->getQueryParams();
$code = array_get($queryParams, 'code');
$state = array_get($queryParams, 'state');
if (!$code) {
$authUrl = $this->provider->getAuthorizationUrl($this->getAuthorizationUrlOptions());
$session->set('oauth2state', $this->provider->getState());
return new RedirectResponse($authUrl . '&display=popup');
} elseif (!$state || $state !== $session->get('oauth2state')) {
$session->forget('oauth2state');
echo 'Invalid state. Please close the window and try again.';
exit;
}
$this->token = $this->provider->getAccessToken('authorization_code', compact('code'));
$owner = $this->provider->getResourceOwner($this->token);
$identification = $this->getIdentification($owner);
$suggestions = $this->getSuggestions($owner);
return $this->authResponse->make($request, $identification, $suggestions);
}
示例8: getAuthorizationUrl
public function getAuthorizationUrl($options = array())
{
return parent::getAuthorizationUrl(array_merge(['approval_prompt' => []], $options));
}
示例9: testAuthorizationUrlStateParam
public function testAuthorizationUrlStateParam()
{
$this->assertContains('state=XXX', $this->provider->getAuthorizationUrl(['state' => 'XXX']));
}
示例10: getAuthorizationUrl
public function getAuthorizationUrl($options = [])
{
$url = parent::getAuthorizationUrl($options);
$url .= '&type=web_server';
return $url;
}
示例11: getAuthorizationUrl
public function getAuthorizationUrl($options = [])
{
return parent::getAuthorizationUrl(['state' => $this->getState()]) . '&company_id=' . $this->companyId;
}
示例12: getAuthorizationUrl
public function getAuthorizationUrl($options = array())
{
$url = parent::getAuthorizationUrl($options);
return $url;
}
示例13: getAuthorizationUrl
/**
* {@inheritDoc}
*/
public function getAuthorizationUrl($options = [])
{
$url = parent::getAuthorizationUrl();
// This is required as an option to be given a refresh token
if (isset($options["duration"])) {
$url .= "&duration={$options['duration']}";
}
return $url;
}