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

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

diimolabs/laravel-oauth2-client
===============================

Package to handle communication with authorization between microservices

1.0.3(5y ago)12174MITPHPPHP &gt;=7.4

Since Jul 20Pushed 5y ago2 watchersCompare

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

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

OAuth2 between Laravel projects
===============================

[](#oauth2-between-laravel-projects)

A package that allows secure communication between two or more projects, focused mainly for use in microservices architectures, adding the Oauth2 authorization standard in addition to security at the network level by IP addresses and whitelists, which may already be owned.

Features
--------

[](#features)

- Simple implementation
- It does not increase the latency of requests between microservices.
- High level of security

Prerequisites
-------------

[](#prerequisites)

1. Having an authorization server, it is recommended to use [Laravel Passport](https://laravel.com/docs/8.x/passport#client-credentials-grant-tokens) for this, specifically in the [Client Credentials Grant Tokens](https://laravel.com/docs/8.x/passport#client-credentials-grant-tokens) section
2. Store the file `oauth-public.key` at folder `storage/app/` in the microservices to communicate, this file is provided by the authorization server

Installation
------------

[](#installation)

1. Import the library

    ```
    composer require diimolabs/laravel-oauth2-client

    ```
2. Add the following environment variables:

    ```
    OAUTH_HOST=
    OAUTH_CLIENT_ID=
    OAUTH_CLIENT_SECRET=

    ```

    And fill with the data provided by the authorization server when creating the client corresponding to the project
3. Implement the `middleware` that validates the authorization of the input requests, in the file `app/Http/kernel.php`

    ```
    protected $routeMiddleware = [
        // Other middleware...
        'jwt' => \Diimolabs\OAuth\Middleware\EnsureJwtIsValid::class
    ];
    ```

Use
---

[](#use)

Example of requesting a resource to a microservice

```
use Diimolabs\OAuth\Facades\OAuthClient;
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->group(function(){
    Route::get('message', function(){
        return OAuthClient::request()
            ->get('http://msa-2.test/api/v1/hello-world')
            ->body();
    });
});
```

Example of a request from a microservice client

```
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->middleware('jwt')->group(function ()
{
    Route::get('/hello-world', function ()
    {
        return 'Hello world from microservice 2';
    });
});
```

Extra
=====

[](#extra)

import the configuration file using:

```
php artisan vendor:publish --tag=oauth-client

```

in `external_services` you can manage the urls of your different services

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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.

###  Release Activity

Cadence

Every ~2 days

Total

4

Last Release

1846d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35673133?v=4)[Javier Villatoro](/maintainers/JVillator0)[@JVillator0](https://github.com/JVillator0)

---

Top Contributors

[![JVillator0](https://avatars.githubusercontent.com/u/35673133?v=4)](https://github.com/JVillator0 "JVillator0 (12 commits)")

---

Tags

jwtjwt-authorizationlaravellaravel-frameworklaravel-packagemachine-to-machineoauth2oauth2-authorizationlaraveloauthauthorizationmicroservices

### Embed Badge

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

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k113.1M996](/packages/laravel-socialite)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

121269.8k1](/packages/ellaisys-aws-cognito)[google/auth

Google Auth Library for PHP

1.4k302.1M240](/packages/google-auth)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k53](/packages/civicrm-civicrm-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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