rmasters/oauth2-assembla

v1.0 2015-11-02 10:50 UTC

This package is not auto-updated.

Last update: 2024-09-18 11:06:52 UTC


README

此包为 The PHP League OAuth2 Client 提供一个简单的 Assembla 提供者。

## 使用

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());

许可证

MIT 许可证