PHPackages                             webiny/oauth2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. webiny/oauth2

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

webiny/oauth2
=============

Webiny OAuth2 Component

v1.6.1(8y ago)4731MITPHPPHP ^7

Since Sep 19Pushed 8y ago9 watchersCompare

[ Source](https://github.com/Webiny/OAuth2)[ Packagist](https://packagist.org/packages/webiny/oauth2)[ Docs](http://www.webiny.com/)[ RSS](/packages/webiny-oauth2/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (6)Versions (23)Used By (1)

OAuth2 Wrappers
===============

[](#oauth2-wrappers)

This component provides wrappers for several OAuth2 systems like Facebook, LinkedIn and Google. After you have gained OAuth2 access token, you can use this wrapper to communicate with the the desired service.

Install the component
---------------------

[](#install-the-component)

The best way to install the component is using Composer.

```
composer require webiny/oauth2
```

For additional versions of the package, visit the [Packagist page](https://packagist.org/packages/webiny/oauth2).

Supported OAuth2 servers
------------------------

[](#supported-oauth2-servers)

Current supported OAuth2 servers are:

- Facebook
- Google
- LinkedIn

Configuring the component
-------------------------

[](#configuring-the-component)

To use the component, you first need to configure it. The configuration is done by defining the following params:

- **Server** - class that will be used to process the response from OAuth2 server
- **ClientId** - OAuth2 client id
- **ClientSecret** - OAuth2 client secret
- **Scope** - scope parameter based on the selected OAuth2 server
- **RedirectUri** - location where the user will be redirected by the OAuth2 server once he is authorized

### Example configuration:

[](#example-configuration)

```
    OAuth2:
        Facebook:
            Server: \Webiny\Component\OAuth2\Server\Facebook
            ClientId: 273234862555915
            ClientSecret: fe5G55632eeabc2086f8209a3ff05g22
            Scope: email
            RedirectUri: '/security/login-fb/'
        GPlus:
            Server: \Webiny\Component\OAuth2\Server\Google
            ClientId: 716241231612.apps.googleusercontent.com
            ClientSecret: KyP8Eag3a60Jgb3mkgiuPFdZYl
            Scope: openid%20profile%20email
            RedirectUri: '/security/login-gp/'
```

Usage
-----

[](#usage)

This component depends on users access token, without it no API call to the OAuth2 server can be made. To get the access token, please read the implementation guide for a specific server you wish to use. OAuth2 components is also integrated with the `Security` component as a user and authentication provider, automating the process of getting the required auth token.

Example:

```
// load instance of `GPlus` configuration
$instance = OAuth2Loader::getInstance('GPlus');

// set access token
$instance->setAccessToken('...');

// do API requests to get user details
$userProfile = $instance->request()->getUserDetails();

// do an API request to a specific API method
$result = $instance->request()->rawRequest($url, $params);
```

Registering additional servers
------------------------------

[](#registering-additional-servers)

First create a class that extends `\Webiny\Component\OAuth2\AbstractServer` and then implement the abstract methods. All of the abstract methods are described inside `AbstractServer` class, and additionally you should also check out how implementations of current servers looks like. They are located in `\Webiny\Component\OAuth2\Server` folder.

```
class Instagram extends \Webiny\Component\OAuth2\AbstractServer
{
    public function getAuthorizeUrl(){
        // TODO: Implement _getUserDetailsTargetData() method.
    }

    public function getAccessTokenUrl(){
        // TODO: Implement _getUserDetailsTargetData() method.
    }

	protected function _getUserDetailsTargetData() {
		// TODO: Implement _getUserDetailsTargetData() method.
	}

	protected function _processUserDetails($result) {
		// TODO: Implement _processUserDetails() method.
	}

	public function processAuthResponse($response) {
		// TODO: Implement processAuthResponse() method.
	}
}
```

Once you have implemented your logic for the abstract methods, it's time to register the class with the OAuth2 component. In order to do so, inside your config file, set the value of `Server` property to your newly created class.

```
    OAuth2:
        Instagram:
            Server: \MyLib\OAuth2\Server\Instagram
            ...
```

And you're done! To use it, just configure it the same way as the built in classes.

Notice
------

[](#notice)

The code on this component is not fully covered by unit test. Only main classes are tested, while tests for `Bridge` and `Server` still need to be written.

Resources
---------

[](#resources)

To run unit tests, you need to use the following command:

```
$ cd path/to/Webiny/Component/OAuth2/
$ composer.phar install
$ phpunit

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~52 days

Recently: every ~5 days

Total

22

Last Release

3153d ago

PHP version history (3 changes)1.0.x-devPHP &gt;=5.4.0

v1.2.0PHP &gt;=5.5.9

1.5.x-devPHP ^7

### Community

Maintainers

![](https://www.gravatar.com/avatar/4440afa738ed146b05c06073a90345e0464c4f4d042b039532d881ca24859d77?d=identicon)[SvenAlHamad](/maintainers/SvenAlHamad)

---

Top Contributors

[![SvenAlHamad](https://avatars.githubusercontent.com/u/3808420?v=4)](https://github.com/SvenAlHamad "SvenAlHamad (22 commits)")

---

Tags

oauth2facebook oauth2google oauth2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webiny-oauth2/health.svg)

```
[![Health](https://phpackages.com/badges/webiny-oauth2/health.svg)](https://phpackages.com/packages/webiny-oauth2)
```

###  Alternatives

[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[league/oauth2-facebook

Facebook OAuth 2.0 Client Provider for The PHP League OAuth2-Client

32013.0M66](/packages/league-oauth2-facebook)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
