Social OAuth Authentication for Laravel 5. drivers: facebook, github, google, linkedin, weibo, qq, wechat and douban

Overview

Laravel-socialite

Sponsor me

Installation

$ composer require "overtrue/laravel-socialite:~3.0"

if you have been installed the overtrue/socialite package, please remove it from composer.json before this command.

Configuration

  1. You will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/socialite.php or config/services.php configuration file, and should use the key facebook, twitter, linkedin, google, github or bitbucket, depending on the providers your application requires. For example:


return [
    //...
    'github' => [
        'client_id'     => 'your-app-id',
        'client_secret' => 'your-app-secret',
        'redirect'      => 'http://localhost/socialite/callback.php',
    ],
    //...
];

Usage



namespace App\Http\Controllers;

use Socialite;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class AuthController extends Controller
{
    /**
     * Redirect the user to the GitHub authentication page.
     */
    public function redirectToProvider()
    {
        return redirect()->to(Socialite::create('github')->redirect());
    }

    /**
     * Obtain the user information from GitHub.
     */
    public function handleProviderCallback(Request $request)
    {
        $user = Socialite::create('github')->userFromCode($request->query('code'));

        // $user->getId();
        // $user->getNickname();
        // ...
    }
}

And register routes:

Route::get('/oauth/github', 'AuthController@redirectToProvider');
Route::get('/oauth/github/callback', 'AuthController@handleProviderCallback');

About more usage, please refer to overtrue/socialite.

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT

Comments
  • laravel5.4 session set应该改为put

    laravel5.4 session set应该改为put

    安神,你好,laravel5.4中,session的set()方法应该更换成put()

    引用5.4中的升级说明 Symfony兼容性#

    Laravel 的会话处理程序不再实现 Symfony 的 SessionInterface 。 实现这个接口需要我们实现框架不需要的无关特性。取而代之,已经定义了新的 Illuminate\Contracts\Session\Session 接口,并且可以使用。还应该修改一下代码:

    所有调用 ->set() 方法应该更改为 ->put() 。通常,Laravel 应用从不调用 set 方法,因为它从未在 Laravel 文档中记录。不过,谨慎起见,这里我们依然罗列出来。

    所有调用 ->getToken() 方法的地方需要修改为 ->token() 。

    所有调用 $request->setSession() 方法的地方需要求改为 setLaravelSession() 。

    opened by moore0903 4
  • 使用Google登录,可以redirect,但获取超时

    使用Google登录,可以redirect,但获取超时

    目前只测试了用 Google 登录,测试地址是:https://demo.365sy.com/oauth/google 返回超时。如果是服务器之间的通信问题,不应该有返回参数,如:https://demo.365sy.com/oauth/google/callback?state=7b9129f11eacc911264eef0ea313592e0c77235d&code=4/5LZy-2yHwmXlkbopoWO3L4OQDSSeIZ7-tPMVhXHvusI&authuser=0&session_state=af1163bacd1e5ea237d2c6f4ef851591aca6bc8c..30d0&prompt=none#

    代码完全按照DEMO写的,只不过把github改成google

    opened by liuyami 2
  • Is this support wechat and weibo?

    Is this support wechat and weibo?

    Is this support wechat and weibo?I have no idea about this,and reported "Call to undefined method Overtrue\LaravelSocialite\Socialite::driver()",can you help me?

    opened by cynhard 2
  • Update overtrue/socialite requirement from ~2.0 to ~3.0

    Update overtrue/socialite requirement from ~2.0 to ~3.0

    Updates the requirements on overtrue/socialite to permit the latest version.

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 1
  • Type error: Argument 1 passed to Overtrue\Socialite\SocialiteManager::formatConfig() must be of the type array, null given, called in /.../vendor/overtrue/socialite/src/SocialiteManager.php on line 149

    Type error: Argument 1 passed to Overtrue\Socialite\SocialiteManager::formatConfig() must be of the type array, null given, called in /.../vendor/overtrue/socialite/src/SocialiteManager.php on line 149

    I know there is another Issue opened with this same error, but i still can't solve it.

    After the user authorizes my App into his/her Facebook, is redirected to this error.

    Type error: Argument 1 passed to Overtrue\Socialite\SocialiteManager::formatConfig() must be of the type array, null given, called in /.../vendor/overtrue/socialite/src/SocialiteManager.php on line 149

    I noticed the overtrue/laravel-socialite/config.php file is empty.

    Is there some configuration file missing?

    I already tried: php artisan vendor:publish php artisan config:cache

    But none worked, what should i do?

    Laravel Framework 5.4.32

    opened by rbenvenuto 1
  • 测试使用github api登陆报错

    测试使用github api登陆报错

    Type error: Argument 1 passed to Overtrue\Socialite\SocialiteManager::formatConfig() must be of the type array, null given, called in /Users/meilunzhi/Code/Project/vendor/overtrue/socialite/src/SocialiteManager.php on line 138

    opened by SummerMagic 1
  • Upgrade to GitHub-native Dependabot

    Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.

    dependencies 
    opened by dependabot-preview[bot] 0
  • 偶尔报错code_is_reused_error

    偶尔报错code_is_reused_error

    [2020-05-07 20:03:26] production.ERROR: Authorize Failed: {"callback({"error":100020,"error_description":"code_is_reused_error"});\n":""} {"exception":"[object] (Overtrue\Socialite\AuthorizeFailedException(code: -1): Authorize Failed: {"callback({\"error\":100020,\"error_description\":\"code_is_reused_error\"});
    ":""} at /home/www/wwwroot/blog/vendor/overtrue/socialite/src/Providers/AbstractProvider.php:448) 老哥啥原因啊

    opened by nfhh 0
  • 与包 socialiteproviders/weixin 会有冲突

    与包 socialiteproviders/weixin 会有冲突

    与包 socialiteproviders/weixin 会有冲突,希望添加到 composer.json 的 conflict 中

    详细原因见。 https://learnku.com/laravel/t/10002/invalidargumentexception-with-message-driver-weixin-not-supported#reply85573

    opened by mouyong 0
Releases(4.0.1)
Owner
安正超
Keep calm and coding.
安正超
Symfony bundle to publish status updates on Facebook, LinkedIn and Twitter.

Upgrading? Check the upgrade guide. What's this? This is a Symfony bundle written in PHP 7.1 that wraps martin-georgiev/social-post - an easy way for

Martin Georgiev 37 Oct 30, 2022
via this package you can push notifications to [ Facebook , Twitter , Telegram , Linkedin ] ( Laravel )

Push To Social [ Facebook , Twitter , Telegram , Linkedin ] via this package you can push notifications to [ Facebook , Twitter , Telegram , Linkedin

Peter Tharwat 29 Nov 4, 2022
Login Menggunakan Google, Github, & Facebook

Login Oauth 2 Karena agak rumit untuk menjelaskan, ikuti tutorial berikut untuk mengatur CLIENTID dan CLIENTSECRET mu terlebih dahulu klik. Server Req

Fadhlurrahman 1 Nov 24, 2021
PHPoAuthLib provides oAuth support in PHP 7.2+ and is very easy to integrate with any project which requires an oAuth client.

PHPoAuthLib NOTE: I'm looking for someone who could help to maintain this package alongside me, just because I don't have a ton of time to devote to i

David Desberg 1.1k Dec 27, 2022
EAuth extension allows to authenticate users by the OpenID, OAuth 1.0 and OAuth 2.0 providers

EAuth extension allows to authenticate users with accounts on other websites. Supported protocols: OpenID, OAuth 1.0 and OAuth 2.0.

Maxim Zemskov 330 Jun 3, 2022
Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Introduction Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitL

The Laravel Framework 5.2k Dec 27, 2022
OAuth 1/2 Provider implementations for chillerlan/php-oauth-core. PHP 7.4+

chillerlan/php-oauth-providers Documentation See the wiki for advanced documentation. Requirements PHP 7.4+ a PSR-18 compatible HTTP client library of

chillerlan 4 Dec 2, 2022
A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package

laravel-social A Laravel 5 package for OAuth Social Login/Register implementation using Laravel socialite and (optionally) AdminLTE Laravel package. I

Sergi Tur Badenas 42 Nov 29, 2022
This module is intended to provide oauth authentication to freescout.

OAuth FreeScout This module is intended to provide oauth authentication to freescout. Module was tested on keycloak oauth provider with confidential o

Michael Bolsunovskyi 9 Dec 21, 2022
Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system.

Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system. Built on Bootstrap 4.

Jeremy Kenedy 2.8k Dec 31, 2022
It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

Sami Alateya 10 Aug 3, 2022
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

Rinvex Authy Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest AP

Rinvex 34 Feb 14, 2022
PHP class to generate and verify Google Authenticator 2-factor authentication

Google Authenticator PHP class Copyright (c) 2012-2016, http://www.phpgangsta.de Author: Michael Kliewe, @PHPGangsta and contributors Licensed under t

Michael Kliewe 2.1k Jan 2, 2023
Google Two-Factor Authentication Package for Laravel

Google2FA for Laravel Google Two-Factor Authentication Package for Laravel Google2FA is a PHP implementation of the Google Two-Factor Authentication M

Antonio Carlos Ribeiro 785 Dec 31, 2022
An OAuth 2.0 bridge for Laravel and Lumen [DEPRECATED FOR LARAVEL 5.3+]

OAuth 2.0 Server for Laravel (deprecated for Laravel 5.3+) Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now features the P

Luca Degasperi 2.4k Jan 6, 2023
phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

Apereo Foundation 780 Dec 24, 2022
A One Time Password Authentication package, compatible with Google Authenticator.

Google2FA Google Two-Factor Authentication for PHP Google2FA is a PHP implementation of the Google Two-Factor Authentication Module, supporting the HM

Antonio Carlos Ribeiro 1.6k Dec 30, 2022
Simple PHP Google Authentication Template

php-google-auth A php google authentication page project View Demo · Report Problems About The Project This is a small and easy project that I made to

Antonio 4 Nov 21, 2021
Enables Google Authentication for YOURLS

google-auth-yourls Enables Google Authentication for YOURLS Proper documentation coming soon. For now, here is the very rough documentation: Download

8th Wall 14 Nov 20, 2021