kaiyum2012/socialite-auth

Plug and use of Laravel Socialite package for Laravel App

dev-master 2021-12-19 17:16 UTC

This package is auto-updated.

Last update: 2024-04-19 22:26:42 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

Supported social providers

  • Google
  • GitHub and

more on the way!

Installation

You can install the package via composer:

composer require kaiyum2012/socialite-auth

Laravel without auto-discovery: If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Kaiyum2012\SocialiteAuth\SocialiteAuthServiceProvider::class,

Usage

Set following env variables.

SOCIAL_AUTH_PROVIDERS= #e.g. github|facebook|google|twitter
SOCIAL_AUTH_ROUTE=/auth/social
SOCIAL_AUTH_CALLBACK=/auth/social/callback

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_AUTH_CALLBACK= #example: https://finance.local/auth/social/callback/github

GOOGLE_CLIENT_ID= #
GOOGLE_CLIENT_SECRET= #
GOOGLE_REDIRECT= #example: https://finance.local/auth/social/callback/google

Set URLs as following:

Auth Route

route('socialite-auth.route',{'provider':{provider}})
# {provider} = github|google
# e.g route('socialite-auth.route',{'provider':'github'})

Callback Route

route('socialite-auth.callback',{'provider':{provider}})
# {provider} = github|google
# e.g route('socialite-auth.callback',{'provider':'github'})

Migration

php artisan migrate

Configuration

User Model should implement Sociable Contract

class User implements Sociable

and use HasSocialAccounts trait to implement Sociable Contract

use HasSocialAccounts;

For some reason if you would like to override New user creation using social account can be done as following:

 public function createUserUsing(array $attributes = []): Sociable
 {
      return $this->fill($attributes);
 }

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email abdulkaiyum.creatrix@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Special Thanks to Laravel Package Boilerplate.