2017-25 © Pedro Peláez
 

library oauth2-amazon

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

image

luchianenco/oauth2-amazon

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  • Wednesday, September 13, 2017
  • by luchianenco
  • Repository
  • 1 Watchers
  • 2 Stars
  • 2,289 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 27 % Grown

The README.md

Amazon Provider for OAuth 2.0 Client

Latest Version Build Status Total Downloads, (*1)

This package provides Amazon OAuth 2.0 support for the PHP League's OAuth 2.0 Client., (*2)

Installation

To install the package, use composer:, (*3)

composer require luchianenco/oauth2-amazon

Usage

Usage is the same as The League's OAuth client, using \Luchianenco\OAuth2\Client\Provider\Amazon as the provider., (*4)

Authorization Code Flow


$provider = new Luchianenco\OAuth2\Client\Provider\Amazon([ 'clientId' => '{amazon-client-id}', 'clientSecret' => '{amazon-client-secret}', 'redirectUri' => 'https://example.com/callback_url', ]); // Send OAuth Request // If we don't have an authorization code then we can get one $authUrl = $provider->getAuthorizationUrl(); $_SESSION['OAuth2State'] = $provider->getState(); ... // OAuth2 Callback URL // Compare given state against previously stored one to block CSRF attack if (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['OAuth2State'])) { exit('Invalid state'); } else { // Try to get an access token $token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]); // Now we can look up users profile try { // Get the user's details $user = $provider->getResourceOwner($token); printf('Hello %s!', $user->getName()); } catch (Exception $e) { // Failed to get user details exit('Oh no ... ...'); } // We can use token to make other API calls echo $token->getToken(); }

Testing

bash $ ./vendor/bin/phpunit, (*5)

The Versions

13/09 2017

dev-master

9999999-dev

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2

13/09 2017

1.1.0

1.1.0.0

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2

13/09 2017

1.0.4

1.0.4.0

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2

13/09 2017

1.0.3

1.0.3.0

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2

12/09 2017

1.0.2

1.0.2.0

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2

12/09 2017

1.0.1

1.0.1.0

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2

08/09 2017

1.0

1.0.0.0

Amazon OAuth 2.0 Client Provider for The PHP League OAuth2-Client

  Sources   Download

MIT

The Requires

 

The Development Requires

authentication authorization oauth amazon client oauth2