PHPackages                             webthink/guzzle-jwt - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. webthink/guzzle-jwt

AbandonedLibrary[HTTP &amp; Networking](/categories/http)

webthink/guzzle-jwt
===================

This package contains useful classes and interfaces for requiring a JWT token

v1.1.0(6y ago)526.0k↓100%1[1 PRs](https://github.com/webthinkgr/guzzle-jwt-middleware/pulls)MITPHPPHP &gt;=7.1CI failing

Since Aug 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/webthinkgr/guzzle-jwt-middleware)[ Packagist](https://packagist.org/packages/webthink/guzzle-jwt)[ Docs](https://github.com/webthinkgr/guzzle-jwt-middleware)[ RSS](/packages/webthink-guzzle-jwt/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (5)Versions (12)Used By (0)

A guzzle middleware for JWT authentication.
===========================================

[](#a-guzzle-middleware-for-jwt-authentication)

[![codecov](https://camo.githubusercontent.com/b3f0a27dc1ee45efce591574c5bc48ec8f179600a968bc17705ad75780900566/68747470733a2f2f636f6465636f762e696f2f67682f7765627468696e6b67722f67757a7a6c652d6a77742d6d6964646c65776172652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/webthinkgr/guzzle-jwt)[![Build Status](https://camo.githubusercontent.com/3204968a2ae53942a2ad67b9ba0df0a87929d4926ce064c50309fa4987281471/68747470733a2f2f7472617669732d63692e6f72672f7765627468696e6b67722f67757a7a6c652d6a77742d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/webthinkgr/guzzle-jwt)[![SensioLabsInsight](https://camo.githubusercontent.com/e5d6d13a2b2c24b95bef79b403a81fc6922c1d1d4ada361a2fcb242a9e9a5506/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61386165656164612d653234642d343437342d623761342d3731346662643764393433322f6d696e692e706e67)](https://insight.sensiolabs.com/projects/a8aeeada-e24d-4474-b7a4-714fbd7d9432)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/webthinkgr/guzzle-jwt/blob/master/LICENSE)

Goal of this package is to provide a set of useful classes in order to use a JWT authentication with Guzzle.

Install
-------

[](#install)

You can install the package using composer

`composer require webthink/guzzle-jwt`

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

As a first step you need to implement your own Authenticator.

```
class MyAuthenticator implements AuthenticatorInterface
{
    public function authenticate($username, $password)
    {
    // code.. and return a TokenInterface.
    }
}
```

Then you need to append into your handler stack the middleware provided by the package.

```
// Your handler stack
$stack = HandlerStack::create();

// Add middleware
$stack->append(new Middleware($myAuthenticator));

$httpClient = new Client([
    'handler' => $stack,
    'jwt' => [
        'username' => 'username',
        'password' => 'password',
    ],
]);

$response = $httClient->get('/my_api_that_requires_jwt_token');
```

**NOTE**

I will not proceed with creating classes that implement the `AuthenticatorInterface`. The AuthenticatorInterface can be implemented by the developer who uses the package.

### Storages

[](#storages)

Storages are a way of caching JWT between multiple requests. Depending on the storage the token can for using it for more than one HTTP Request.

In order to use the storage you will need either to implement an Authenticator of your own that will use the storage or use the `StoreAuthenticator`

```
$myAuthenticator = new MyAuthenticator();
$storeAuthenticator = new StoreAuthenticator($myAuthenticator, new MemoryStorage());
```

Then you can pass the store authenticator in the middleware and follow the procedure described above.

Contributing
------------

[](#contributing)

Feel free to comment on anything you might believe it's going in the wrong direction or even better contribute with a PR.

Todo
----

[](#todo)

- Increase UnitTests.
- Investigate the possibility of including some authenticators.

Credits
-------

[](#credits)

- [George Mponos](https://github.com/gmponos)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

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 ~177 days

Recently: every ~211 days

Total

6

Last Release

2317d ago

Major Versions

v0.4.0 → v1.0.02019-01-05

PHP version history (2 changes)v0.1.0PHP &gt;=5.5.38

v1.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/30258b48a25c5d879451cd83ce8a2f24ab14745852c07bd40f4f24d87a6ffa51?d=identicon)[gmponos](/maintainers/gmponos)

---

Top Contributors

[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (78 commits)")

---

Tags

authenticationguzzlehttpjwtjwt-authenticationmiddlewarepsr7httpjwtmiddlewareGuzzlewebthink

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webthink-guzzle-jwt/health.svg)

```
[![Health](https://phpackages.com/badges/webthink-guzzle-jwt/health.svg)](https://phpackages.com/packages/webthink-guzzle-jwt)
```

###  Alternatives

[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43117.4M104](/packages/kevinrob-guzzle-cache-middleware)[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28722.5k3](/packages/eljam-guzzle-jwt-middleware)[rtheunissen/guzzle-log-middleware

Guzzle middleware to log requests and responses

842.3M17](/packages/rtheunissen-guzzle-log-middleware)[caseyamcl/guzzle_retry_middleware

Guzzle v6+ retry middleware that handles 429/503 status codes and connection timeouts

21610.7M64](/packages/caseyamcl-guzzle-retry-middleware)[php-http/guzzle7-adapter

Guzzle 7 HTTP Adapter

9057.1M555](/packages/php-http-guzzle7-adapter)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

916.4M49](/packages/graham-campbell-guzzle-factory)

PHPackages © 2026

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