PHPackages                             axm/socialite - 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. [Framework](/categories/framework)
4. /
5. axm/socialite

ActiveLibrary[Framework](/categories/framework)

axm/socialite
=============

OAuth for Axm

1.0.13(2y ago)066MITPHPPHP ^8.1

Since Nov 16Pushed 2y agoCompare

[ Source](https://github.com/Axm-framework/socialite)[ Packagist](https://packagist.org/packages/axm/socialite)[ Docs](https://axmphp.com)[ RSS](/packages/axm-socialite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (12)Used By (0)

Axm Socialite
=============

[](#axm-socialite)

[![Latest Stable Version](https://camo.githubusercontent.com/4335ab19e78d8e170f50d1e0b5f1f2492ae3f7c5541005bb458e7d1ebbe169bf/68747470733a2f2f706f7365722e707567782e6f72672f61786d2f536f6369616c6974652f762f737461626c65)](https://packagist.org/packages/axm/Socialite)[![Total Downloads](https://camo.githubusercontent.com/fcbef2711d2da91224c306ec0279a78b5e56dea70c9143219d475cf77dcb123a/68747470733a2f2f706f7365722e707567782e6f72672f61786d2f536f6369616c6974652f646f776e6c6f616473)](https://packagist.org/packages/axm/Socialite)[![License](https://camo.githubusercontent.com/076960204533a4f14d897ebbcd9a77460175eb7f94e676d00fe79e93ca6e4489/68747470733a2f2f706f7365722e707567782e6f72672f61786d2f536f6369616c6974652f6c6963656e7365)](https://packagist.org/packages/axm/Socialite)

📦 Installation
--------------

[](#-installation)

To install the component, add the following to your `composer.json` file:

```
{
    "require": {
        "axm/socialite": "^1.0"
    }
}
```

You can also use [Composer](https://getcomposer.org/) to install Axm in your project quickly.

```
composer require axm/Socialite
```

Then, run `composer update` to install the package.

Configuration
-------------

[](#configuration)

Once the package is installed, you need to configure it. Open the `.env` file and add the following lines:

```
GOOGLE_CLIENT_ID="YOUR_GOOGLE_CLIENT_ID"
GOOGLE_CLIENT_SECRET="YOUR_GOOGLE_CLIENT_SECRET"
GOOGLE_REDIRECT="${APP_URL}/YOUR_GOOGLE_REDIRECT_URI"

FACEBOOK_CLIENT_ID="YOUR_FACEBOOK_CLIENT_ID"
FACEBOOK_CLIENT_SECRET="YOUR_FACEBOOK_CLIENT_SECRET"
FACEBOOK_REDIRECT="${APP_URL}/YOUR_FACEBOOK_REDIRECT_URI"
```

Be sure to replace the placeholders with your actual Google and Facebook client IDs, client secrets, and redirect URIs.

Usage
-----

[](#usage)

To use the component, simply add the following line to your route file:

```
Route::get('/auth-redirect/{provider:\w+}', [App\Raxm\AuthComponent::class, 'handlerAuthRedirect']);
Route::get('/auth-google-callback', [App\Raxm\AuthComponent::class, 'handlerRediretGoogleAuth']);
```

This route will redirect the user to the authentication page of the specified provider.

Once the user has authenticated, they will be redirected back to your application. The `handleSocialAuthRedirect` method will then be called. This method will check if the user is already logged in. If they are, they will be redirected to the home page. If they are not, they will be registered as a new user and then redirected to the home page.

Example
-------

[](#example)

The following example shows how to use the component to authenticate users with Google and FaceBook, usage in your controller:

```
