PHPackages                             pletfix/oauth-plugin - 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. pletfix/oauth-plugin

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

pletfix/oauth-plugin
====================

OAuth Plugin for Pletfix

15PHP

Since Oct 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/pletfix/oauth-plugin)[ Packagist](https://packagist.org/packages/pletfix/oauth-plugin)[ RSS](/packages/pletfix-oauth-plugin/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

OAuth Plugin for Pletfix
========================

[](#oauth-plugin-for-pletfix)

About This
----------

[](#about-this)

This plugin provides a OAuth service to authenticate the user through the social networking service provider such like Facebook or Dropbox.

Currently the following drivers are integrated:

- Dropbox
- Facebook
- GitHub
- Spotify

You are welcome when you make a pull request with other social media drivers.

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

[](#installation)

Fetch the package by running the following terminal command under the application's directory:

```
composer require pletfix/oauth-plugin

```

After downloading, enter this command in your terminal to register the plugin:

```
php console plugin pletfix/oauth-plugin

```

Environment and Configuration
-----------------------------

[](#environment-and-configuration)

Open the configuration file `./config/oauth.php` under the application's directory and override the defaults if you wish.

Customize
---------

[](#customize)

### View

[](#view)

If you have installed the [Pletfix Application Skeleton](https://github.com/pletfix/app), you could add the necessary menu items ("login" and "logout") by including the partial `_nav` in your `resources/views/app.blade.php` layout just above the marker `{{--menu_point--}}`:

```
   @include('oauth._nav')

```

### Routes

[](#routes)

If you like to use another route paths, copy the route entries from `./vendor/pletfix/oauth-plugin/boot/routes.php`into the application's routing file `./boot/routes.php`, where you can modify them as you wish:

```
$route->get('oauth/{provider}/login',  'OAuthController@login');
$route->post('oauth/{provider}/login', 'OAuthController@login');

```

Usage
-----

[](#usage)

### User Authentication

[](#user-authentication)

Enter the following URL into your Browser to redirect to the login screen to your OAuth provider:

```
https:///oauth//login

```

You must replace the placeholder "" with one of the providers configured in the configuration file `config/oauth.php`, for example with Facebook:

```
https:///oauth/facebook/login

```

#### User Model

[](#user-model)

If you have defined a user model in the configuration, the user attributes are stored in the database. By default, the user model from the [Pletfix Application Skeleton](https://github.com/pletfix/app) is used and no further migration is required.

#### Logout

[](#logout)

You may invoke just the following command to logout the user:

```
auth()->logout();

```

### OAuth Service

[](#oauth-service)

#### Accessing the OAuth service

[](#accessing-the-oauth-service)

You can get an instance of the OAuth Service from the Dependency Injector via the OAuth Factory:

```
/** @var Pletfix\OAuth\Services\Contracts\OAuth $oauth */
$oauth = DI::getInstance()->get('oauth-factory')->provider($provider);

```

You can also use the `oauth()` function to get the OAuth service, it is more comfortable:

```
$oauth = oauth();

```

#### Available Methods

[](#available-methods)

#### `authorize()`

[](#authorize)

Authorize the application through the OAuth provider.

```
if (!$oauth->authorize()) {
    return redirect('')->withError('Forbidden!');
}

```

After authorization the access token is set and you can get the account information with the `getAccount` method.

#### `getAccount()`

[](#getaccount)

Get the authenticated account information.

```
$user = $oauth->getAccount();

```

The return value is an array with following attributes:

```
- id    (string) The unique identifier of the account.
- name  (string) The display name of the user.
- email (string) The email address of the user.
```

#### `setAccessToken`

[](#setaccesstoken)

Set the access token.

```
$oauth->setAccessToken($accessToken);

```

The access token is set automatically after the authorization, see the `authorize` method.

#### `getAccessToken()`

[](#getaccesstoken)

Get the access token.

```
$accessToken = $oauth->getAccessToken();

```

The access token is available if the user was authenticated or if you have set a token manually by the `setAccessToken`method.

#### `hasAccessToken()`

[](#hasaccesstoken)

Determine if the access token is exist.

```
$isAuthorized = $oauth->hasAccessToken();

```

Contribution Guide
------------------

[](#contribution-guide)

Are you missing a social media driver? Then fork the repository, add a new driver in the `Drivers/SocialMedia` directory and make a pull request. There are already a few drivers, which you can orientate to the development. You'll see, it's not too difficult.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

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/64489babc88aa87c56b4097f2a4fe20233d1a3ee63ce0da7c2cc2f97a883f444?d=identicon)[frohlfing](/maintainers/frohlfing)

---

Top Contributors

[![frohlfing](https://avatars.githubusercontent.com/u/9631952?v=4)](https://github.com/frohlfing "frohlfing (21 commits)")

### Embed Badge

![Health badge](/badges/pletfix-oauth-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/pletfix-oauth-plugin/health.svg)](https://phpackages.com/packages/pletfix-oauth-plugin)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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