Git Product home page Git Product logo

laravel-socialite's Introduction

Laravel Socialite

Laravel Octane Ready Status GitHub release (latest SemVer) GitHub License Packagist Downloads

Sponsor me

Installation

$ composer require "overtrue/laravel-socialite"

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:
 <?php

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

Usage

<?php

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

laravel-socialite's People

Contributors

bangbangda avatar dependabot-preview[bot] avatar overtrue avatar remxcode avatar summerblue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-socialite's Issues

偶尔报错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)
老哥啥原因啊

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() 。

使用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

关于更新

请问,我看到您socialite已经更新到支持8.0,这个 laravel 的包也会更新吗?

Driver for twitter

This package does not support twitter, Giving me erro Driver[twitter] not supported. Please suggest something, or please add it's support in package.

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?

Laravel5.5安装有问题

我发现你你的composer里面添加了laravel5.5增加的extra这个字段,自动注入porvider和alias,那么我安装完之后,发现vendor目录中的laravel-soclite文件是空的,请解决一下!

测试使用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

感谢大佬

我操了你的代码,公司使用的Lumen,不太想搞session支持,第三方登录的state改成外部传递了,借助redis可以保存更多的零时数据。感谢大佬开源

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.