当前位置: 首页>>代码示例>>PHP>>正文


PHP AbstractProvider::getState方法代码示例

本文整理汇总了PHP中League\OAuth2\Client\Provider\AbstractProvider::getState方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractProvider::getState方法的具体用法?PHP AbstractProvider::getState怎么用?PHP AbstractProvider::getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在League\OAuth2\Client\Provider\AbstractProvider的用法示例。


在下文中一共展示了AbstractProvider::getState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:knpuniversity,项目名称:oauth2-client-bundle,代码行数:20,代码来源:OAuth2Client.php

示例2: moveToAuth

 private function moveToAuth(AbstractProvider $provider)
 {
     $authorizationUrl = $provider->getAuthorizationUrl();
     $_SESSION['oauth2state'] = $provider->getState();
     header('Location: ' . $authorizationUrl);
     exit;
 }
开发者ID:cass-project,项目名称:cass,代码行数:7,代码来源:AbstractCommand.php

示例3: 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);
 }
开发者ID:flarum,项目名称:core,代码行数:27,代码来源:AbstractOAuth2Controller.php

示例4: setStateToken

 /**
  * Set the state token string from a provider to the user's session.
  *
  * @param AbstractProvider $provider
  */
 public function setStateToken(AbstractProvider $provider)
 {
     $this->session->set(self::SESSION_STATE, $provider->getState());
 }
开发者ID:bolt,项目名称:Members,代码行数:9,代码来源:Session.php


注:本文中的League\OAuth2\Client\Provider\AbstractProvider::getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。