PHPackages                             mahfuz05/laravel-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. mahfuz05/laravel-oauth2

ActiveLibrary

mahfuz05/laravel-oauth2
=======================

0661PHP

Since Jun 19Pushed 10y ago1 watchersCompare

[ Source](https://github.com/mahfuz05/oauth2-client)[ Packagist](https://packagist.org/packages/mahfuz05/laravel-oauth2)[ RSS](/packages/mahfuz05-laravel-oauth2/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Creative Commons License](https://camo.githubusercontent.com/627f8381f39aaac7fd5516a4eb37d169132626708878080d77999e11b1321eea/687474703a2f2f692e6372656174697665636f6d6d6f6e732e6f72672f6c2f62792d6e632d6e642f342e302f38307831352e706e67)](http://creativecommons.org/licenses/by-nc-nd/4.0/)
This work is licensed under a [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nc-nd/4.0/).

Laravel OAuth2 - Client
=======================

[](#laravel-oauth2---client)

 This Package can be used to connect to an OAuth2-Service and fetch OAuth2 restricted resources. this is Laravel OAuth rapper for

1. Installation
---------------

[](#1-installation)

### via Composer

[](#via-composer)

 Update your `composer.json` "require"-Section with this line:

    ```

    "mahfuz05/laravel-oauth2": "dev-master"

```

 After adding this line, run the following command:

    ```

    composer install
    or
    composer update

```

2. Configuration
----------------

[](#2-configuration)

 You need to publish the configuration file of this package with:

    ```

    php artisan config:publish  mahfuz05/laravel-oauth2

```

 The Config-File path is `app/config/mahfuz05/laravel-oauth2/config.php`

 Here you have to add/modify the values for your purpose.
 \[client.id\] - Client-ID of your Application
 \[client.secret\] - Client-Secret of your Application
 \[scopes\] - Scopes for your Application (comma separated)

 After modifying the Package-Config, update the `app/config/app.php`
 Modify your **providers and aliases** section, with your preferred alias:

```
'providers' => 'Mahfuz05\LaravelOauth2\LaravelOauth2ServiceProvider'

'aliases' => 'LaravelOauth2'	=> 'Mahfuz05\LaravelOauth2\Facades\LaravelOauth2'

```

3. Examples
-----------

[](#3-examples)

### Fetch Access-Token

[](#fetch-access-token)

    ```

    LaravelOauth2::fetchAccessToken('http://3rd.party.com/api/access_token', 'password', array(
        'username'	=> $credentials['username'],
        'password'	=> $credentials['password'],
        'scope'		=> Config::get('oauth2-client::scopes'),
    ));

```

### Requesting a OAuth2 - Restricted Resource/URL

[](#requesting-a-oauth2---restricted-resourceurl)

    ```

    $result = LaravelOauth2::fetch('http://3rd.party.com/api/restriced/resource');

```

### Or you can use like this

[](#or-you-can-use-like-this)

      ```

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

                $auth_url = LaravelOauth2::getAuthenticationUrl($this->url, $this->redirectUri);
                header('Location: ' . $auth_url);
                die('Redirect');
            }
            else
            {
                $params = array('code' => $_GET['code'], 'redirect_uri' => $this->redirectUri);

                $response = LaravelOauth2::getAccessToken($this->token_url, 'authorization_code', $params);

                //get Access Token and store it

                LaravelOauth2::setAccessToken($response['result']['access_token']);
                $token = $response['result']['access_token'];

                //get all customers

                $response = LaravelOauth2::fetch('https://api.debitoor.com/api/v1.0/customers');
            }

```

`4. ConstantsAuth methods    AUTH_TYPE_URI    AUTH_TYPE_AUTHORIZATION_BASIC    AUTH_TYPE_FORMAccess token types    ACCESS_TOKEN_URI    ACCESS_TOKEN_BEARER    ACCESS_TOKEN_OAUTH    ACCESS_TOKEN_MACGrant types    GRANT_TYPE_AUTH_CODE    GRANT_TYPE_PASSWORD    GRANT_TYPE_CLIENT_CREDENTIALS    GRANT_TYPE_REFRESH_TOKENHTTP Methods    HTTP_METHOD_GET    HTTP_METHOD_POST    HTTP_METHOD_PUT    HTTP_METHOD_DELETE    HTTP_METHOD_HEAD    HTTP_METHOD_PATCHHTTP Form content types    HTTP_FORM_CONTENT_TYPE_APPLICATION    HTTP_FORM_CONTENT_TYPE_MULTIPART`

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2733e3e72a472f2da94705f13ec599b0f5c8d397f62709a3d17201e5b313ebd0?d=identicon)[mahfuz](/maintainers/mahfuz)

---

Top Contributors

[![mahfuz05](https://avatars.githubusercontent.com/u/523780?v=4)](https://github.com/mahfuz05 "mahfuz05 (3 commits)")

### Embed Badge

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

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

PHPackages © 2026

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