PHP code example of rmasters / oauth2-assembla
1. Go to this page and download the library: Download rmasters/oauth2-assembla library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rmasters / oauth2-assembla example snippets
$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());