Skip to content

πŸ” This package provides Invision's OAuth 2 and supports League's OAuth 2.0 client.

License

Notifications You must be signed in to change notification settings

emidas/oauth2-invision

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

oauth2-invision

This package provides Invision's OAuth 2 and supports League's OAuth 2.0 client.


πŸš€ Download and installation

This package is available on Packagist. You can install it directly via Composer with the command composer req emidas/oauth2-invision.

πŸ“– Example

<?php

require __DIR__ . '/vendor/autoload.php';
session_start();

$invisionProvider = new emidas\OAuth2\Client\InvisionProvider([
    'baseUrl' => '', // The base URL of your Invision Community
    'clientId' => '', // The client ID of your application
    'clientSecret' => '', // The client secret of your application
    'redirectUri' => '' // The callback URI where the user will be redirected
]);

if (isset($_GET['code'])) {
    if ($_SESSION['oauth2_state'] !== $_GET['state'])
        exit('The returned state doesn\'t match with your local state.');
    $invisionToken = $invisionProvider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
    $invisionUser = $invisionProvider->getResourceOwner($invisionToken);
    echo 'Your primary group name is: ' . $invisionUser->getPrimaryGroup()->getName();
    echo 'Your email is: ' . $invisionUser->getEmail();
} else {
    $oauthUrl = $invisionProvider->getAuthorizationUrl();
    $_SESSION['oauth2_state'] = $invisionProvider->getState();
    header('Location: ' . $oauthUrl);
}

About

πŸ” This package provides Invision's OAuth 2 and supports League's OAuth 2.0 client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%