rmasters / oauth2-assembla
v1.0
2015-11-02 10:50 UTC
Requires
- php: >=5.5.0
- league/oauth2-client: ~1.0
This package is not auto-updated.
Last update: 2024-11-13 12:01:36 UTC
README
This package provides a simple Assembla provider for The PHP League OAuth2 Client.
## Usage
composer require rmasters/oauth2-assembla
$provider = new Assembla([ 'clientId' => getenv('ASSEMBLA_CLIENT_ID'), 'clientSecret' => getenv('ASSEMBLA_CLIENT_SECRET'), 'redirectUri' => getenv('ASSEMBLA_REDIRECT_URI'), ]); // Send to Assembla for authorization if (!isset($_GET['code'])) { header('Location: ' . $provider->getAuthorizationUrl()); exit; } // Get an access token from an authorization code $token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]); $_SESSION['assembla'] = $token; // Get the authenticated user $user = $provider->getResourceOwner($token); assert($user instanceof AssemblaResourceOwner); printf("Logged in as %s", $user->getName());