PHP Web App
Choose API Version:
V3 V2

View the full sample project on Github

Step 1. Add dependencies

Add the oauth2-client dependency to your composer.json and install with php composer.phar install

    "require": {
      "league/oauth2-client": "^1.1"

Step 2. Configure your client settings and secrets

$provider = new \League\OAuth2\Client\Provider\GenericProvider([
    'clientId'                => '[YOUR_CLIENT_ID]',
    'clientSecret'            => '[YOUR_CLIENT_SECRET]',
    'redirectUri'             => '[YOUR_REDIRECT_URI]',
    'urlAuthorize'            => '',
    'urlAccessToken'          => '',
    'urlResourceOwnerDetails' => ''

Step 3. Redirect the user to's OAuth 2.0 server

Generate the authorization endpoint URL

$authorizationUrl = $provider->getAuthorizationUrl();

Redirect the user to $authorizationUrl

header('Location: ' . filter_var($authorizationUrl, FILTER_SANITIZE_URL));

Step 4. Exchange the code for an access token

Use the getAccessToken method to exchange the authorization code for an access token

$accessToken = $provider->getAccessToken('authorization_code', [
    'code' => $_GET['code'], 'scope' => 'kyc'

Step 5. Call's API

Use the access token to call's API and retrieve the user's attributes

$payload = $provider->getResourceOwner($accessToken)->toArray();

You can check the user's attributes via $payload['attributes'] and $payload['status'] arrays.