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


PHP StdOAuth2Token::setRefreshToken方法代码示例

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


在下文中一共展示了StdOAuth2Token::setRefreshToken方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseAccessTokenResponse

 protected function parseAccessTokenResponse($responseBody)
 {
     if (version_compare($this->apiVersion, 'v2.2', '>') === true) {
         $data = json_decode($responseBody, true);
     } else {
         parse_str($responseBody, $data);
     }
     if (null === $data || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         if (is_array($data['error']) === true) {
             $errorMessage = $data['error']['message'];
         } else {
             $errorMessage = $data['error'];
         }
         throw new TokenResponseException('Error in retrieving token: "' . $errorMessage . '"');
     }
     $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;
 }
开发者ID:recca0120,项目名称:socialite,代码行数:31,代码来源:Facebook.php

示例2: parseAccessTokenResponse

 /**
  * Parses the access token response and returns a TokenInterface.
  *
  *
  * @param string $responseBody
  *
  * @return TokenInterface
  *
  * @throws TokenResponseException
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $request = \Request::getInstance();
     if ($request->get('error')) {
         $reason = $request->get('error_description');
         throw new TokenResponseException($reason);
     }
     $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']);
     $token->setLifetime($data['expires_in']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     unset($data['expires_in']);
     $data['state'] = $request->get('state');
     $token->setExtraParams($data);
     return $token;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:36,代码来源:Community.php

示例3: parseAccessTokenResponse

 /**
  * {@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['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     unset($data['access_token']);
     $token->setExtraParams($data);
     return $token;
 }
开发者ID:davenorthcreek,项目名称:stratum,代码行数:21,代码来源:Bullhorn.php

示例4: parseAccessTokenResponse

 /**
  * {@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']);
     // Salesforce tokens evidently never expire...
     $token->setEndOfLife(StdOAuth2Token::EOL_NEVER_EXPIRES);
     unset($data['access_token']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         unset($data['refresh_token']);
     }
     $token->setExtraParams($data);
     return $token;
 }
开发者ID:RewardGateway,项目名称:PHPoAuthLib,代码行数:23,代码来源:Salesforce.php

示例5: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ?
     parse_str($responseBody, $data);
     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']);
     $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;
 }
开发者ID:carriercomm,项目名称:sticky-notes,代码行数:24,代码来源:Facebook.php

示例6: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $JSON = new \JSON(JSON_LOOSE_TYPE);
     $data = $JSON->decode($responseBody);
     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;
 }
开发者ID:araname,项目名称:dokuwiki-plugin-oauth,代码行数:26,代码来源:Auth0.php

示例7: refreshAccessToken

 public function refreshAccessToken()
 {
     $access_token = $this->access_token;
     $service = Facades\Social::service($this->provider);
     if (2 === Facades\Social::oauthSpec($this->provider)) {
         $token = new StdOAuth2Token();
         $token->setAccessToken(array_get($access_token, 'token'));
         $token->setRefreshToken(array_get($access_token, 'refresh_token'));
     } else {
         $token = new StdOAuth1Token();
         $token->setAccessToken(array_get($access_token, 'token'));
         $token->setAccessTokenSecret(array_get($access_token, 'secret'));
         $token->setRefreshToken(array_get($access_token, 'refresh_token'));
     }
     $service->getStorage()->storeAccessToken(ucfirst($this->provider), $token);
     try {
         $new_token = $service->refreshAccessToken($token);
     } catch (\Exception $e) {
         return false;
     }
     if (!$new_token->getAccessToken()) {
         return false;
     }
     $access_token['token'] = $new_token->getAccessToken();
     if ($new_token->getEndOfLife()) {
         $access_token['end_of_life'] = $new_token->getEndOfLife();
     }
     if ($new_token->getExtraParams()) {
         $access_token['extra_params'] = $new_token->getExtraParams();
     }
     if (2 !== Facades\Social::oauthSpec($this->provider) && $new_token->getAccessTokenSecret()) {
         $access_token['secret'] = $new_token->getAccessTokenSecret();
     }
     $this->access_token = $access_token;
     $this->save();
     return true;
 }
开发者ID:mmanos,项目名称:laravel-social,代码行数:37,代码来源:Provider.php

示例8: parseAccessTokenResponse

 /**
  * @param string $responseBody
  * @return StdOAuth2Token
  * @throws TokenResponseException
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = $this->service->parseAccessTokenResponse($responseBody);
     if (!isset($data) || !is_array($data)) {
         throw new TokenResponseException('Unable to parse response.');
     }
     $error = $this->service->getAccessTokenResponseError($data);
     if (isset($error)) {
         throw new TokenResponseException('Error in retrieving token: "' . $error . '"');
     }
     $token = new StdOAuth2Token();
     $names = $this->service->getAccessTokenArgumentNames();
     $token->setAccessToken($data[$names['access_token']]);
     unset($data[$names['access_token']]);
     if (isset($data[$names['expires_in']])) {
         $token->setLifeTime($data[$names['expires_in']]);
         unset($data[$names['expires_in']]);
     } else {
         $token->setLifetime($this->service->getTokenDefaultLifetime());
     }
     if (isset($data[$names['refresh_token']])) {
         $token->setRefreshToken($data[$names['refresh_token']]);
         unset($data[$names['refresh_token']]);
     }
     $token->setExtraParams($data);
     return $token;
 }
开发者ID:barbq,项目名称:yii2eauth,代码行数:32,代码来源:ServiceProxy.php

示例9: parseAccessTokenResponse

 /**
  * {@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']);
     // Salesforce access tokens depend on the session timeout settings.
     // The session timeout for an access token can be configured in Salesforce from Setup by clicking Security Controls | Session Settings.
     $token->setEndOfLife(StdOAuth2Token::EOL_UNKNOWN);
     unset($data['access_token']);
     if (isset($data['refresh_token'])) {
         $token->setRefreshToken($data['refresh_token']);
         // Save Refresh Token persistently until it is cleared manually
         update_option('gf_salesforce_refreshtoken', $data['refresh_token']);
         unset($data['refresh_token']);
     } else {
         $refresh_token = get_option('gf_salesforce_refreshtoken');
         if (!empty($refresh_token)) {
             $token->setRefreshToken($refresh_token);
         }
     }
     $token->setExtraParams($data);
     return $token;
 }
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:31,代码来源:Salesforce.php

示例10: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     $data = @json_decode($responseBody, true);
     // Facebook gives us a query string on old api (v2.0)
     if (!$data) {
         parse_str($responseBody, $data);
     }
     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;
 }
开发者ID:RewardGateway,项目名称:PHPoAuthLib,代码行数:29,代码来源:Facebook.php

示例11: parseAccessTokenResponse

 /**
  * {@inheritdoc}
  */
 protected function parseAccessTokenResponse($responseBody)
 {
     parse_str($responseBody, $data);
     if (null === $data || !is_array($data) || empty($data)) {
         throw new TokenResponseException('Unable to parse response.');
     } elseif (isset($data['error'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
     } elseif (isset($data['error_reason'])) {
         throw new TokenResponseException('Error in retrieving token: "' . $data['error_reason'] . '"');
     }
     $token = new StdOAuth2Token();
     $token->setAccessToken($data['access_token']);
     $token->setLifeTime($data['expires']);
     // I hope one day Deezer add a refresh token :)
     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;
 }
开发者ID:DevSlashNull,项目名称:PHPoAuthLib,代码行数:26,代码来源:Deezer.php


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