[ https://jira.fiware.org/browse/HELP-9190?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] José Ignacio Carretero Guarde resolved HELP-9190. ------------------------------------------------- Resolution: Done > [fiware-stackoverflow] Fi-ware IDM - Oauth2 php cliente configuration > --------------------------------------------------------------------- > > Key: HELP-9190 > URL: https://jira.fiware.org/browse/HELP-9190 > Project: Help-Desk > Issue Type: Monitor > Components: FIWARE-TECH-HELP > Reporter: Backlog Manager > Assignee: Alvaro Alonso > Labels: fiware, oauth, oauth-2.0, php > > Created question in FIWARE Q/A platform on 15-08-2015 at 09:08 > {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/32022622/fi-ware-idm-oauth2-php-cliente-configuration > +Question:+ > Fi-ware IDM - Oauth2 php cliente configuration > +Description:+ > I'm trying to use the FiWare Identity Management - KeyRock that provides a Oauth 2.0 login. I have configured my app in the Fiware web page to set the url and callback url and I have got my client ID and my password. > Now I'm trying to use the API with a simple PHP client Oauth2.0 library. I've choosen this. It looks very easy to use, but I have a problem: > When I open my web, I'm correctly redirected to the fi-ware login web page, but once i logged, I'm not redirected to my web page callback page, I continue in the fi-ware labs web page. > That's my code: > index.php: > <?php > require_once 'vendor/autoload.php'; > use fkooman\OAuth\Client\Guzzle6Client; > use fkooman\OAuth\Client\ClientConfig; > use fkooman\OAuth\Client\SessionStorage; > use fkooman\OAuth\Client\Api; > use fkooman\OAuth\Client\Context; > $clientConfig = new ClientConfig( > array( > 'authorize_endpoint' => 'https://account.lab.fi-ware.org', > 'client_id' => 'my_client_id', > 'client_secret' => 'my_secret', > 'token_endpoint' => 'http://estebanxabi.miwp.eu/otros/callback.php', > ) > ); > $tokenStorage = new SessionStorage(); > $httpClient = new Guzzle6Client(); > $api = new Api('foo', $clientConfig, $tokenStorage, $httpClient); > $context = new Context('sampleEmail', array('authorizations')); > $accessToken = $api->getAccessToken($context); > if (false === $accessToken) { > /* no valid access token available, go to authorization server */ > header('HTTP/1.1 302 Found'); > header('Location: '.$api->getAuthorizeUri($context)); > exit; > } > echo 'Access Token: '.$accessToken->getAccessToken(); > and callback.php: > <?php > require_once 'vendor/autoload.php'; > use fkooman\OAuth\Client\Guzzle6Client; > use fkooman\OAuth\Client\ClientConfig; > use fkooman\OAuth\Client\SessionStorage; > use fkooman\OAuth\Client\Callback; > $clientConfig = new ClientConfig( > array( > 'authorize_endpoint' => 'https://account.lab.fi-ware.org', > 'client_id' => 'client_ide', > 'client_secret' => 'seceret', > 'token_endpoint' => 'http://estebanxabi.miwp.eu/otros/callback.php', > ) > ); > try { > $tokenStorage = new SessionStorage(); > $httpClient = new Guzzle6Client(); > $cb = new Callback('foo', $clientConfig, $tokenStorage, $httpClient); > $cb->handleCallback($_GET); > header('HTTP/1.1 302 Found'); > header('Location: http://localhost/fkooman/php-oauth-client/example/simple6/index.php'); > exit; > } catch (fkooman\OAuth\Client\Exception\AuthorizeException $e) { > // this exception is thrown by Callback when the OAuth server returns a > // specific error message for the client, e.g.: the user did not authorize > // the request > die(sprintf('ERROR: %s, DESCRIPTION: %s', $e->getMessage(), $e->getDescription())); > } catch (Exception $e) { > // other error, these should never occur in the normal flow > die(sprintf('ERROR: %s', $e->getMessage())); > } -- This message was sent by Atlassian JIRA (v6.4.1#64016)
You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy Cookies policy