PHPackages                             iget-master/token-auth - 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. iget-master/token-auth

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

iget-master/token-auth
======================

A simple token based authentication guard for Laravel 5.2

v2.0.0(9y ago)10696[1 issues](https://github.com/iget-master/token-auth/issues)PHPPHP &gt;=5.6.0

Since Jan 6Pushed 9y ago3 watchersCompare

[ Source](https://github.com/iget-master/token-auth)[ Packagist](https://packagist.org/packages/iget-master/token-auth)[ RSS](/packages/iget-master-token-auth/feed)WikiDiscussions master Synced today

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

Laravel 5.2 - Token-based Guard
===============================

[](#laravel-52---token-based-guard)

Using this guard, you can login your user like the default Laravel `session` guard, but the authorization will be persisted using a token passed through `Authorization` HTTP Header.

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

[](#installation)

1. Require `iget-master/token-auth` on composer
2. Add the `IgetMaster\TokenAuth\TokenAuthServiceProvider::class` services provider on `app.php` configuration file.
3. Change your guard driver to `iget-token` on `auth.php`

Usage
-----

[](#usage)

As on Laravel's default session guard, you must use `Auth::attempt` using the user credentials to try to login. If successful, you can use `Auth::getToken()` to get the 16 characters random Authorization Token.

On subsequent requests, the user should pass a `Authorization` http header with this token. If the token is valid, the user will be authenticated and you will be able to get current user using `Auth::user()`.

If you are using the Laravel's default AuthController, you must update it, since you should send to the user the Authorization Token. Here is an example of `AuthController@getLogin` method:

```
/**
 * @param \Request $request
 * @return \Illuminate\Http\JsonResponse
 */
public function getLogin(Request $request)
{
	$success = false;

	if (Auth::attempt($request->only(['email', 'password']))) {
		$success = true;
		$token = Auth::getToken();
		$user_id = Auth::user()->id;
	}

	return response()->json(compact('success', 'token', 'user_id'));
}
```

**Remember** to include the Request class at top of your controller class:

```
use Illuminate\Http\Request;
```

You should change `session.lifetime` configuration to change the token's lifetime.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 84.2% 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 ~103 days

Total

5

Last Release

3416d ago

Major Versions

v1.1.2 → v2.0.02017-02-22

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9434959?v=4)[We are IGET](/maintainers/iget-master)[@iget-master](https://github.com/iget-master)

---

Top Contributors

[![iget-esoares](https://avatars.githubusercontent.com/u/9450290?v=4)](https://github.com/iget-esoares "iget-esoares (16 commits)")[![iget-master](https://avatars.githubusercontent.com/u/9434959?v=4)](https://github.com/iget-master "iget-master (3 commits)")

### Embed Badge

![Health badge](/badges/iget-master-token-auth/health.svg)

```
[![Health](https://phpackages.com/badges/iget-master-token-auth/health.svg)](https://phpackages.com/packages/iget-master-token-auth)
```

###  Alternatives

[laravel/octane

Supercharge your Laravel application's performance.

4.0k24.7M206](/packages/laravel-octane)[statamic/cms

The Statamic CMS Core Package

4.8k3.5M925](/packages/statamic-cms)[laravel/nightwatch

The official Laravel Nightwatch package.

3618.7M32](/packages/laravel-nightwatch)

PHPackages © 2026

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