예제 #1
0
 /**
  * Creates an Access Token from an Refresh Token.
  *
  * @path /v1/identity/openidconnect/tokenservice
  * @method POST
  * @param array $params (allowed values are grant_type and scope)
  * 				(optional) refresh_token refresh token. If one is not passed, refresh token from the current object is used.
  * 				(optional) grant_type is the Token grant type. Defaults to refresh_token
  * 				scope is an array that either the same or a subset of the scope passed to the authorization request
  * @param APIContext $apiContext Optional API Context   
  * @return PPOpenIdTokeninfo
  */
 public function createFromRefreshToken($params, $apiContext = null)
 {
     static $allowedParams = array('grant_type' => 1, 'refresh_token' => 1, 'scope' => 1);
     if (is_null($apiContext)) {
         $apiContext = new PPApiContext();
     }
     if (!array_key_exists('grant_type', $params)) {
         $params['grant_type'] = 'refresh_token';
     }
     if (!array_key_exists('refresh_token', $params)) {
         $params['refresh_token'] = $this->getRefreshToken();
     }
     $call = new PPRestCall($apiContext);
     $this->fromJson($call->execute(array('PPOpenIdHandler'), "/v1/identity/openidconnect/tokenservice", "POST", http_build_query(array_intersect_key($params, $allowedParams)), array('Content-Type' => 'application/x-www-form-urlencoded')));
     return $this;
 }
예제 #2
0
 /**
  * returns user details
  *
  * @path /v1/identity/openidconnect/userinfo
  * @method GET
  * @param array $params (allowed values are access_token)
  * 					access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls  
  * @param PPApiContext $apiContext Optional API Context
  * @return PPOpenIdUserinfo
  */
 public static function getUserinfo($params, $apiContext = null)
 {
     static $allowedParams = array('schema' => 1);
     if (is_null($apiContext)) {
         $apiContext = new PPApiContext();
     }
     if (!array_key_exists('schema', $params)) {
         $params['schema'] = 'openid';
     }
     $requestUrl = "/v1/identity/openidconnect/userinfo?" . http_build_query(array_intersect_key($params, $allowedParams));
     $call = new PPRestCall($apiContext);
     $ret = new PPOpenIdUserinfo();
     $ret->fromJson($call->execute(array('PPOpenIdHandler'), $requestUrl, "GET", "", array('Authorization' => "Bearer " . $params['access_token'], 'Content-Type' => 'x-www-form-urlencoded')));
     return $ret;
 }