/** * Returns the URL to which the user must be redirected to * logout from the OpenID provider (i.e. PayPal) * * @param string $redirectUri Uri on merchant website to where * the user must be redirected to post logout * @param string $idToken id_token from the TokenInfo object * @param PPApiContext $apiContext Optional API Context */ public static function getLogoutUrl($redirectUri, $idToken, $apiContext = null) { if (is_null($apiContext)) { $apiContext = new PPApiContext(); } $config = $apiContext->getConfig(); $params = array('id_token' => $idToken, 'redirect_uri' => $redirectUri, 'logout' => 'true'); return sprintf("%s/v1/endsession?%s", self::getBaseUrl($config), http_build_query($params)); }
/** * * @param string $method - API method to call * @param object $requestObject Request object * @param apiContext $apiContext object containing credential and SOAP headers * @param array $handlers Array of Handlers * @param mixed $apiUserName - Optional API credential - can either be * a username configured in sdk_config.ini or a ICredential object created dynamically */ public function call($port, $method, $requestObject, $apiContext, $handlers = array()) { if (!is_array($handlers)) { $handlers = array(); } if (is_array($this->handlers)) { $handlers = array_merge($this->handlers, $handlers); } if ($apiContext == null) { $apiContext = new PPApiContext(PPConfigManager::getConfigWithDefaults($this->config)); } if ($apiContext->getConfig() == null) { $apiContext->setConfig(PPConfigManager::getConfigWithDefaults($this->config)); } $service = new PPAPIService($port, $this->serviceName, $this->serviceBinding, $apiContext, $handlers); $ret = $service->makeRequest($method, new PPRequest($requestObject, $this->serviceBinding)); $this->lastRequest = $ret['request']; $this->lastResponse = $ret['response']; return $this->lastResponse; }
/** * Creates an Access Token from an Authorization Code. * * @path /v1/identity/openidconnect/tokenservice * @method POST * * @param array $params (allowed values are client_id, client_secret, grant_type, code and redirect_uri) * (required) client_id from developer portal * (required) client_secret from developer portal * (required) code is Authorization code previously received from the authorization server * (required) redirect_uri Redirection endpoint that must match the one provided during the * authorization request that ended in receiving the authorization code. * (optional) grant_type is the Token grant type. Defaults to authorization_code * @param PPApiContext $apiContext Optional API Context * * @return PPOpenIdTokeninfo */ public static function createFromAuthorizationCode($params, $clientId, $clientSecret, $apiContext = null) { static $allowedParams = array('grant_type' => 1, 'code' => 1, 'redirect_uri' => 1); if (is_null($apiContext)) { $apiContext = new PPApiContext(); } $config = $apiContext->getConfig(); if ($apiContext->get($clientId) !== false) { $clientId = $apiContext->get($clientId); } if ($apiContext->get($clientSecret) !== false) { $clientSecret = $apiContext->get($clientSecret); } if (!array_key_exists('grant_type', $params)) { $params['grant_type'] = 'authorization_code'; } $call = new PPRestCall($apiContext); $token = new PPOpenIdTokeninfo(); $token->fromJson($call->execute(array(new PPOpenIdHandler()), "/v1/identity/openidconnect/tokenservice", "POST", http_build_query(array_intersect_key($params, $allowedParams)), array('Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Basic ' . base64_encode($clientId . ":" . $clientSecret)))); return $token; }