plutus/oauth2-client-plutus

There is no license information available for the latest version (v1.2.1) of this package.

Plutus 2.0 Client Provider for The PHP League OAuth2-Client

v1.2.1 2021-06-22 08:28 UTC

This package is auto-updated.

Last update: 2024-04-24 19:49:19 UTC


README

This package provides the Plutus Commerce OAuth 2.0 service provider & token for use with the league/oauth2-client package.

The OAuth 2.0 login flow, seen commonly around the web in the form of "Connect with Facebook/Google/etc." buttons, is a common integration added to web applications. The league/oauth2-client package provides a base for integrating with various OAuth 2.0 providers, without overburdening your application with the concerns of RFC 6749.

Requirements

We support the following versions of PHP:

  • PHP 8.0
  • PHP 7.4
  • PHP 7.3

Install

composer require plutus/oauth2-client-plutus

Example

Authorization flow

use League\OAuth2\Client\Provider\PlutusProvider;
use League\OAuth2\Client\Token\PlutusAccessToken;

$options = [
    'clientId'       => 'sso_client_id',    // The client ID assigned to you by the provider
    'clientSecret'   => 'sso_client_secret',   // The client password assigned to you by the provider
    'redirectUri'    => 'sso_redirect_url',
    'identityServer' => 'sso_public_url',
];

$this->provider = new PlutusProvider($options);

Get authorization URL

$authorizationUrl = $this->provider->getAuthorizationUrl();

Get access token from authorization code

$grant = new AuthorizationCode();
$accessToken = $this->provider->getAccessToken($grant, [
    'code' => $request->get('code'),
]);

Get access token from refresh token

$grant = new RefreshToken();

$accessToken = $this->provider->getAccessToken($grant, [
    'refresh_token' => $token->getRefreshToken(), // token is instance of PlutusAccessToken
]);

Get user information

$this->provider->getResourceOwner($accessToken) // instance of PlutusAccessToken

Get JWKS

$this->provider->getJwks()