Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 16, 2024 via composer

league/oauth2-client 2.7.0

OAuth 2.0 Client Library
Package summary
Share
0
issues
1
license
9
MIT
Package created
28 May 2013
Version published
16 Apr 2023
Maintainers
4
Total deps
9
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
9 Packages, Including:
guzzlehttp/guzzle@7.8.1
guzzlehttp/promises@2.0.2
guzzlehttp/psr7@2.6.2
league/oauth2-client@2.7.0
paragonie/random_compat@v9.99.100
psr/http-client@1.0.3
psr/http-factory@1.1.0
ralouphie/getallheaders@3.0.3
symfony/deprecation-contracts@v3.5.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of league/oauth2-client 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
guzzlehttp/guzzle7.8.1112.34 kBMIT
prod
paragonie/random_compatv9.99.1005.93 kBMIT
prod

Visualizations

Frequently Asked Questions

What does league/oauth2-client do?

The league/oauth2-client package offers a platform for smooth integration with various OAuth 2.0 service providers. As a robust OAuth 2.0 client library, this package can interact seamlessly with any OAuth 2.0 provider that sticks to the OAuth 2.0 Authorization Framework. Notably, it comes with a 'GenericProvider' class for hassle-free connection with any service provider leveraging Bearer tokens. The library also encourages customization, allowing you to extend and modify its operations to suit additional functionalities offered by various service providers beyond the standard OAuth 2.0 requirements.

How do you use league/oauth2-client?

To effectively use the league/oauth2-client, you will first need to install it via composer with the command composer require league/oauth2-client. Once installed, you can now integrate various OAuth 2.0 providers. Here's a basic usage example with a GenericProvider :

$provider = new \League\OAuth2\Client\Provider\GenericProvider([
  'clientId'                => 'your-client-id',    // The client ID assigned by the provider
  'clientSecret'            => 'your-client-secret',   // The client password assigned by the provider
  'redirectUri'             => 'your-redirect-uri',
  'urlAuthorize'            => 'provider-url-authorize',
  'urlAccessToken'          => 'provider-url-access-token',
  'urlResourceOwnerDetails' => 'provider-url-resource-owner-details',
]);

// Get authorization code
if (!isset($_GET['code'])) {

    // Options to pass to `getAuthorizationUrl` method
    $options = [
        'scope' => ['email']  // Array of scopes you want to get
    ];

    // Fetch the authorization URL from the provider; this returns the urlAuthorize option and generates and applies any necessary parameters (e.g. state).
    $authorizationUrl = $provider->getAuthorizationUrl($options);

    // Redirect the user to the authorization URL.
    header('Location: ' . $authorizationUrl);
    exit;

// Get access token
} else {
    try {

        // Get an access token using the authorization code grant.
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']
        ]);

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {

        // Failed to get the access token
        exit($e->getMessage());

    }
}

Remember to replace 'your-client-id', 'your-client-secret', 'your-redirect-uri', 'provider-url-authorize', 'provider-url-access-token', and 'provider-url-resource-owner-details' with appropriate details relating to the OAuth service provider you are working with.

Where are the league/oauth2-client docs?

The official documentation for the league/oauth2-client is available at the following location: OAuth 2.0 Client Documentation. This comprehensive guide offers detailed explanations on usage, lists of available official and third-party PHP League provider clients, and instructions on how to implement your own provider client. The guide also provides various practical examples demonstrating how to perform different operations using the library.