Esempio n. 1
0
 /**
  * Authenticates the OAuth access token.
  *
  * This function detects whether an access token has been presented.
  *
  * @param bool $include_request_body if true, also detects access tokens
  * from the request body
  */
 public function initAccessToken($include_request_body = false)
 {
     $this->logger->log(LogLevel::DEBUG, 'SimpleID\\Protocols\\OAuth\\OAuthManager->initAccessToken');
     $bearer_token = $this->initBearerAccessToken($include_request_body);
     if ($bearer_token) {
         $this->access_token = AccessToken::decode($bearer_token);
         return;
     }
     // Try other token types
     $results = $this->mgr->invokeAll('oAuthInitAccessToken');
     $results = array_merge(array_diff($results, array(NULL)));
     if (count($results) == 1) {
         $this->access_token = $results[0];
     }
 }
Esempio n. 2
0
 /**
  * Issues an access token.
  *
  * @param array $scope the scope to be included in the access token
  * @param int $expires_in the time over which the access token will be valid,
  * in seconds, or {@link SimpleID\Protocols\OAuth\Token::TTL_PERPETUAL} if the token is not to expire
  * @param TokenSource $source the source, if any, from which the token is to be
  * generated
  * @param array $additional additional data to be stored on the server for this
  * token
  * @return array an array of parameters that can be included in the OAuth token
  * endpoint response
  */
 public function issueAccessToken($scope = array(), $expires_in = Token::TTL_PERPETUAL, $source = null, $additional = array())
 {
     $results = array();
     $token = AccessToken::create($this, $scope, $expires_in, $source, $additional);
     $results['access_token'] = $token->getEncoded();
     $results['token_type'] = $token->getTokenType();
     if ($expires_in != Token::TTL_PERPETUAL) {
         $results['expires_in'] = $expires_in;
     }
     return $results;
 }