/** * Creates an Access Token from an Authorization Code. * * @path /v1/identity/openidconnect/tokenservice * @method POST * @param array $params (allowed values are grant_type, code and redirect_uri) * (optional) grant_type is the Token grant type. Defaults to authorization_code * code is Authorization code previously received from the authorization server * redirect_uri Redirection endpoint that must match the one provided during the * authorization request that ended in receiving the authorization code. * @param PPApiContext $apiContext Optional API Context * @return PPOpenIdTokeninfo */ public static function createFromAuthorizationCode($params, $apiContext = null) { static $allowedParams = array('grant_type' => 1, 'code' => 1, 'redirect_uri' => 1); if (is_null($apiContext)) { $apiContext = new PPApiContext(); } if (!array_key_exists('grant_type', $params)) { $params['grant_type'] = 'authorization_code'; } $call = new PPRestCall($apiContext); $token = new PPOpenIdTokeninfo(); $token->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 $token; }
/** * @test */ public function testSerializationDeserialization() { $tokenCopy = new PPOpenIdTokeninfo(); $tokenCopy->fromJson($this->token->toJson()); $this->assertEquals($this->token, $tokenCopy); }