oauth2-client is a free, open source identity & access management (iam) project written in PHP and released under MIT. It has 3,819 GitHub stars, 770 forks and 64 open issues, and was last pushed 6 days ago. On this registry it ranks #25 of 36 tracked projects in Identity & Access Management (IAM), with 5 head-to-head comparisons available.

What is oauth2-client?

league/oauth2-client is an MIT-licensed PHP library maintained by The PHP League that provides a reusable base for integrating applications with any OAuth 2.0 service provider, aimed at PHP developers who need to add "Connect with Facebook/Google" style login and token flows without implementing RFC 6749 from scratch.

What it is

The package, published as league/oauth2-client, is a client-side implementation of the OAuth 2.0 Authorization Framework. It lives in the PHP ecosystem and is distributed through Packagist, the standard Composer package repository for PHP. Rather than binding an application to one vendor's flow, it offers a common base that works with any provider conforming to the specification, and it ships out of the box with a GenericProvider class for connecting to services that issue Bearer tokens as defined in RFC 6750.

The concrete problem it solves is the repeated, error-prone work of wiring up the OAuth 2.0 login flow in each application. The README notes that this flow, seen around the web as "Connect with Facebook/Google/etc." buttons, is a common integration but "can be tricky and tedious to do right." This library replaces that hand-rolled integration code, keeping the concerns of RFC 6749 out of the application itself so the same client can be pointed at different providers.

Key capabilities

  • A GenericProvider class that connects to any OAuth 2.0 service provider using Bearer tokens.
  • Compatibility with any provider that conforms to the OAuth 2.0 Authorization Framework described in RFC 6749.
  • An extension and wrapping model for providers that add behaviour beyond the specification.
  • Reference lists of official and third-party provider clients, including Facebook, GitHub, Google, Instagram and LinkedIn.
  • A documented path for building your own provider client, covered under "Implementing a Provider Client".
  • Compliance with PSR-1, PSR-2, PSR-4 and PSR-7, so the library fits PSR-7-based HTTP stacks.
  • Support for a wide PHP range spanning PHP 7.1 through PHP 8.5.

Who uses it and how

  • Web applications adding social or third-party sign-in buttons such as "Connect with Facebook" or "Connect with Google", which the README identifies as the most common integration point.
  • Applications that need to talk to several providers at once, using the common base rather than separate bespoke integration code for each one.
  • Teams that need provider-specific behaviour and therefore extend or wrap the library instead of forking it.
  • Developers whose provider is not yet covered and who publish a new provider client, following the documented implementing-a-provider-client guide.
  • PHP projects on long-lived versions, since the library spans PHP 7.1 up to PHP 8.5.

Getting started

Install the library with Composer using the package name league/oauth2-client, then follow the basic usage guide on the project site at oauth2-client.thephpleague.com for GenericProvider examples.

How it compares

No list of commercial products that this package replaces is provided, and the facts name no directly comparable client library. The closest related projects named are the official and third-party provider clients for Facebook, GitHub, Google, Instagram and LinkedIn, which extend and wrap this library rather than compete with it. On the facts available, it stands alone in this registry.

When to use it — and when not to

It is a library rather than a hosted service, so the surrounding pieces stay with the adopter: redirect endpoints, storage for client credentials and tokens, and session handling all remain your responsibility. Projects outside PHP should look elsewhere, and anyone expecting a drop-in for a provider that deviates from the specification will need a provider-specific client or a custom wrapper around this one. The README is deliberately brief and delegates most detail to the external documentation site, which is worth reading before committing; the repository does carry a notable backlog of 64 open issues, though it remains actively maintained.

project readme (upstream, from github) — read inline

OAuth 2.0 Client

This package provides a base for integrating with OAuth 2.0 service providers.

Gitter Chat Source Code Latest Version Software License Build Status Codecov Code Coverage Total Downloads


The OAuth 2.0 login flow, seen commonly around the web in the form of "Connect with Facebook/Google/etc." buttons, is a common integration added to web applications, but it can be tricky and tedious to do right. To help, we've created the league/oauth2-client package, which provides a base for integrating with various OAuth 2.0 providers, without overburdening your application with the concerns of RFC 6749.

This OAuth 2.0 client library will work with any OAuth 2.0 provider that conforms to the OAuth 2.0 Authorization Framework. Out-of-the-box, we provide a GenericProvider class to connect to any service provider that uses Bearer tokens. See our basic usage guide for examples using GenericProvider.

Many service providers provide additional functionality above and beyond the OAuth 2.0 specification. For this reason, you may extend and wrap this library to support additional behavior. There are already many official and third-party provider clients available (e.g., Facebook, GitHub, Google, Instagram, LinkedIn, etc.). If your provider isn't in the list, feel free to add it.

This package is compliant with PSR-1, PSR-2, PSR-4, and PSR-7. If you notice compliance oversights, please send a patch via pull request. If you're interested in contributing to this library, please take a look at our contributing guidelines.

Requirements

We support the following versions of PHP:

  • PHP 8.5
  • PHP 8.4
  • PHP 8.3
  • PHP 8.2
  • PHP 8.1
  • PHP 8.0
  • PHP 7.4
  • PHP 7.3
  • PHP 7.2
  • PHP 7.1

Provider Clients

We provide a list of official PHP League provider clients, as well as third-party provider clients.

To build your own provider client, please refer to "Implementing a Provider Client."

Usage

For usage and code examples, check out our basic usage guide.

Contributing

Please see our contributing guidelines for details.

License

The MIT License (MIT). Please see LICENSE for more information.

Frequently asked questions

Is oauth2-client free to use?

oauth2-client is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does oauth2-client do?

Easy integration with OAuth 2.0 service providers.

What is oauth2-client written in?

oauth2-client is primarily written in PHP. Its source is publicly available at https://github.com/thephpleague/oauth2-client, and it has 3,819 GitHub stars.