PHPackages                             adamwathan/eloquent-oauth-l4 - 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. adamwathan/eloquent-oauth-l4

AbandonedArchivedLibrary

adamwathan/eloquent-oauth-l4
============================

Stupid simple OAuth authentication with Laravel and Eloquent

v0.2.1(9y ago)48728MITPHPPHP &gt;=5.5.0

Since Apr 1Pushed 8y ago2 watchersCompare

[ Source](https://github.com/adamwathan/eloquent-oauth-l4)[ Packagist](https://packagist.org/packages/adamwathan/eloquent-oauth-l4)[ RSS](/packages/adamwathan-eloquent-oauth-l4/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

> **Important: This package is not actively maintained.** For bug fixes and new features, please fork.

Eloquent OAuth L4
=================

[](#eloquent-oauth-l4)

[![This Project Has Been Deprecated.](https://camo.githubusercontent.com/3ae650fc7228648d06b62681ce7c397abe96e1677840b72cc69c336a0de863c6/687474703a2f2f7777772e7265706f7374617475732e6f72672f6261646765732f302e312e302f6162616e646f6e65642e737667)](http://www.repostatus.org/#abandoned)

> Note: Use the [Laravel 5 package](https://github.com/adamwathan/eloquent-oauth-l5) if you are using Laravel 5.

Eloquent OAuth is a package for Laravel 4 designed to make authentication against various OAuth providers *ridiculously* brain-dead simple. Specify your app keys/secrets in a config file, run a migration and from then on it's just two method calls and you have OAuth integration.

Usage
-----

[](#usage)

Authentication against an OAuth provider is a multi-step process, but I have tried to simplify it as much as possible.

### Authorizing with the provider

[](#authorizing-with-the-provider)

First you will need to define the authorization route. This is the route that your "Login" button will point to, and this route redirects the user to the provider's domain to authorize your app. After authorization, the provider will redirect the user back to your second route, which handles the rest of the authentication process.

To authorize the user, simply return the `OAuth::authorize()` method directly from the route.

```
Route::get('facebook/authorize', function() {
    return OAuth::authorize('facebook');
});
```

### Authenticating within your app

[](#authenticating-within-your-app)

Next you need to define a route for authenticating against your app with the details returned by the provider.

For basic cases, you can simply call `OAuth::login()` with the provider name you are authenticating with. If the user rejected your application, this method will throw an `ApplicationRejectedException` which you can catch and handle as necessary.

The `login` method will create a new user if necessary, or update an existing user if they have already used your application before.

Once the `login` method succeeds, the user will be authenticated and available via `Auth::user()` just like if they had logged in through your application normally.

```
use \AdamWathan\EloquentOAuth\Exceptions\ApplicationRejectedException;
use \AdamWathan\EloquentOAuth\Exceptions\InvalidAuthorizationCodeException;

Route::get('facebook/login', function() {
    try {
        OAuth::login('facebook');
    } catch (ApplicationRejectedException $e) {
        // User rejected application
    } catch (InvalidAuthorizationCodeException $e) {
        // Authorization was attempted with invalid
        // code,likely forgery attempt
    }

    // Current user is now available via Auth facade
    $user = Auth::user();

    return Redirect::intended();
});
```

If you need to do anything with the newly created user, you can pass an optional closure as the second argument to the `login` method. This closure will receive the `$user` instance and a `ProviderUserDetails`object that contains basic information from the OAuth provider, including:

- User ID
- Nickname
- Full Name
- Last Name
- Email
- Avatar URL

```
OAuth::login('facebook', function($user, $details) {
    $user->nickname = $details->nickname;
    $user->name = $details->fullName;
    $user->profile_image = $details->avatar;
    $user->save();
});
```

> Note: The Instagram and Soundcloud APIs do not allow you to retrieve the user's email address, so unfortunately that field will always be `null` for those providers.

Supported Providers
-------------------

[](#supported-providers)

- Facebook
- GitHub
- Google
- LinkedIn
- Instagram
- Soundcloud

> The package is still in it's early infancy obviously. Support will be added for other providers as time goes on.

> Feel free to open an issue if you would like support for a particular provider, or even better, submit a pull request.

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

[](#installation)

Require this package using Composer in your terminal:

`composer require adamwathan/eloquent-oauth-l4`

Add the service provider to the `providers` array in `app/config/app.php`:

```
'providers' => array(
    // ...
    'AdamWathan\EloquentOAuthL4\EloquentOAuthServiceProvider',
    // ...
)
```

Add the facade to the `aliases` array in `app/config/app.php`:

```
'aliases' => array(
    // ...
    'OAuth' => 'AdamWathan\EloquentOAuth\Facades\OAuth',
    // ...
)
```

Publish the configuration file:

`php artisan config:publish adamwathan/eloquent-oauth-l4`

Update your app information for the providers you are using in `app/config/packages/adamwathan/eloquent-oauth-l4/config.php`:

```
'providers' => array(
    'facebook' => array(
        'client_id' => '12345678',
        'client_secret' => 'y0ur53cr374ppk3y',
        'redirect_uri' => URL::to('facebook/login'),
        'scope' => array(),
    )
)
```

> Note: Each provider is preconfigured with the necessary scope to retrieve basic user information as well as the user's email address, so the scope array can usually be left empty unless you need specific additional permissions. Consult the provider's API documentation to find out what permissions are available for the various services.

If you need to change the name of the table used to store OAuth identities, you can do so in the same config file:

```
'table' => 'social_login_tokens',
```

Publish and run the migration:

```
php artisan migrate:publish adamwathan/eloquent-oauth-l4
php artisan migrate

```

All done!

Notes
-----

[](#notes)

Eloquent OAuth is designed to integrate with Laravel's Eloquent authentication driver, so be sure you are using the `eloquent`driver in `app/config/auth.php`. You can define your actual `User` model however you choose and add whatever behavior you need, just be sure to specify the model you are using with its fully qualified namespace in `app/config/auth.php` as well.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.1% 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 ~181 days

Total

5

Last Release

3341d ago

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

v0.2.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3fb69ca14ca0266d852fc2678a6e00db1b3dbf209db9ecfdee3fa9ac913feed?d=identicon)[adamwathan](/maintainers/adamwathan)

---

Top Contributors

[![adamwathan](https://avatars.githubusercontent.com/u/4323180?v=4)](https://github.com/adamwathan "adamwathan (128 commits)")[![colindecarlo](https://avatars.githubusercontent.com/u/682860?v=4)](https://github.com/colindecarlo "colindecarlo (3 commits)")[![alexescg](https://avatars.githubusercontent.com/u/8924176?v=4)](https://github.com/alexescg "alexescg (2 commits)")[![syphernl](https://avatars.githubusercontent.com/u/639906?v=4)](https://github.com/syphernl "syphernl (2 commits)")[![tbuteler](https://avatars.githubusercontent.com/u/330375?v=4)](https://github.com/tbuteler "tbuteler (1 commits)")[![cmgmyr](https://avatars.githubusercontent.com/u/4693481?v=4)](https://github.com/cmgmyr "cmgmyr (1 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (1 commits)")[![schmitzc](https://avatars.githubusercontent.com/u/10464?v=4)](https://github.com/schmitzc "schmitzc (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adamwathan-eloquent-oauth-l4/health.svg)

```
[![Health](https://phpackages.com/badges/adamwathan-eloquent-oauth-l4/health.svg)](https://phpackages.com/packages/adamwathan-eloquent-oauth-l4)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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