unitedworldwrestling/oauth2-athena

PHP League OAuth2-Client 的 Athena OAuth 2.0 客户端提供者

1.0.2 2018-11-05 22:29 UTC

This package is auto-updated.

Last update: 2024-09-19 16:20:28 UTC


README

此包为 PHP League 的 OAuth 2.0 客户端提供 Athena OAuth 2.0 支持。OAuth 2.0 Client

安装

安装时使用 composer

composer require unitedworldwrestling/oauth2-athena

使用方法

使用方法与 The League 的 OAuth 客户端相同,使用 \Unitedworldwrestling\OAuth2\Client\Provider\Athena 作为提供者。

客户端凭证流

$provider = new Unitedworldwrestling\OAuth2\Client\Provider\Athena([
    'clientId'          => '{athena-client-id}',
    'clientSecret'      => '{athena-client-secret}',
    'redirectUri'       => 'https://example.com/callback-url',
    'host'              => 'https://api.instagram.com' // Optional, defaults to https://api.instagram.com
]);


// Try to get an access token (using the https://athena.uww.io/grants/api_key grant)
$token = $provider->getAccessToken('https://athena.uww.io/grants/api_key');

// Optional: Now you have a token you can look up a users profile data
try {

    // We got an access token, let's now get the user's details
    $user = $provider->getResourceOwner($token);

    // Use these details to create a new profile
    printf('Hello %s!', $user->getName());

} catch (Exception $e) {

    // Failed to get user details
    exit('Oh dear...');
}

// Use this to interact with an API on the users behalf
echo $token->getToken();