https://socialiteproviders.github.io/providers/qq.html

1. Installation

// This assumes that you have composer installed globally
composer require socialiteproviders/qq

# 2. Service Provider

  • Remove Laravel\Socialite\SocialiteServiceProvider from your providers[] array in config\app.php if you have added it already.

  • Add \SocialiteProviders\Manager\ServiceProvider::class to your providers[] array in config\app.php.

For example:

'providers' => [
// a whole bunch of providers
// remove 'Laravel\Socialite\SocialiteServiceProvider',
\SocialiteProviders\Manager\ServiceProvider::class, // add
];
  • Note: If you would like to use the Socialite Facade, you need to install it.

# 3. Event Listener

  • Add SocialiteProviders\Manager\SocialiteWasCalled event to your listen[] array in app/Providers/EventServiceProvider.

  • Add your listeners (i.e. the ones from the providers) to the SocialiteProviders\Manager\SocialiteWasCalled[] that you just created.

  • The listener that you add for this provider is 'SocialiteProviders\\QQ\\QqExtendSocialite@handle',.

  • Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.

For example:

/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
'SocialiteProviders\\QQ\\QqExtendSocialite@handle',
],
];

# Reference

# 4. Configuration setup

You will need to add an entry to the services configuration file so that after config files are cached for usage in production environment (Laravel command artisan config:cache) all config is still available.

# Add to config/services.php.

'qq' => [
'client_id' => env('QQ_KEY'),
'client_secret' => env('QQ_SECRET'),
'redirect' => env('QQ_REDIRECT_URI')
],

# 5. Usage

return Socialite::with('QQ')->redirect();

# Lumen Support

You can use Socialite providers with Lumen. Just make sure that you have facade support turned on and that you follow the setup directions properly.

Note: If you are using this with Lumen, all providers will automatically be stateless since Lumen does not keep track of state.

Also, configs cannot be parsed from the services[] in Lumen. You can only set the values in the .env file as shown exactly in this document. If needed, you can also override a config (shown below).

# Stateless

  • You can set whether or not you want to use the provider as stateless. Remember that the OAuth provider (Twitter, Tumblr, etc) must support whatever option you choose.

Note: If you are using this with Lumen, all providers will automatically be stateless since Lumen does not keep track of state.

// to turn off stateless
return Socialite::with('QQ')->stateless(false)->redirect(); // to use stateless
return Socialite::with('QQ')->stateless()->redirect();

# Overriding a config

If you need to override the provider's environment or config variables dynamically anywhere in your application, you may use the following:

$clientId = "secret";
$clientSecret = "secret";
$redirectUrl = "http://yourdomain.com/api/redirect";
$additionalProviderConfig = ['site' => 'meta.stackoverflow.com'];
$config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl, $additionalProviderConfig);
return Socialite::with('QQ')->setConfig($config)->redirect();

# Retrieving the Access Token Response Body

Laravel Socialite by default only allows access to the access_token. Which can be accessed via the \Laravel\Socialite\User->token public property. Sometimes you need access to the whole response body which may contain items such as a refresh_token.

You can get the access token response body, after you called the user() method in Socialite, by accessing the property $user->accessTokenResponseBody;

$user = Socialite::driver('QQ')->user();
$accessTokenResponseBody = $user->accessTokenResponseBody;

# Reference

参考地址:https://laravel-china.org/docs/laravel/5.6/socialite/1418

https://socialiteproviders.github.io/providers/qq.html

laravel5.6 QQ 第三方登录的更多相关文章

  1. 使用QQ第三方登录时,手机应用和网站应用对同一个QQ号,获取到的openid不一样

    使用QQ第三方登录时,手机应用和网站应用对同一个QQ号,获取到的openid不一样openid生成是根据应用的appid和QQ号的一些信息加密生成,对于一个appid和QQ号来说,openid是唯一的 ...

  2. 【第三方登录】之QQ第三方登录

    最近公司做了个网站,需要用到第三方登录的东西.有QQ第三方登录,微信第三方登录.先把QQ第三方登录的代码列一下吧. public partial class QQBack : System.Web.U ...

  3. QQ第三方登录

    QQ第三方登录 在Android应用程序的开发过程中,很多时候需要加入用户登录/注册模块.除了自己动手设计登录界面并实现相应功能外,现在还可以借助百度.腾讯等开发者平台提供的第三方账号登录模块.最近研 ...

  4. PHP实现QQ第三方登录

    PHP实现QQ第三方登录 学习之前,请大家先看一下oAuth协议. 首先呢,我们进入QQ互联的官方网站 http://connect.qq.com登入我们自己的QQ号,没有QQ号的小伙伴可以忽略本篇博 ...

  5. 利用JS_SDK实现QQ第三方登录

    前言 现如今,第三方登录已成为大部分网站必备的一项基础技能,引入时髦的第三方登录不仅能帮你吸引更多的用户,也让你的网站可以充分利用其他大型网站的用户资源.本次教程将让你的网站最快捷便利地引入QQ登录. ...

  6. web实现QQ第三方登录

    开放平台-web实现QQ第三方登录   应用场景     web应用通过QQ登录授权实现第三方登录.   操作步骤     1  注册成为QQ互联平台开发者,http://connect.qq.com ...

  7. Android 实现QQ第三方登录

    Android 实现QQ第三方登录 在项目中需要实现QQ第三方登录,经过一番努力算是写出来了,现在总结以下,以防以后遗忘,能帮到其他童鞋就更好了. 首先肯定是去下载SDK和DEMO http://wi ...

  8. Android应用之——最新版本号SDK V2.4实现QQ第三方登录

    为什么要写这篇博客呢?由于.我在做这个第三方登录的时候,找了非常多资料,发现要么就是过时了.要么就是说的非常不清楚.非常罗嗦.并且非常多都是一些小demo,不是什么实例.甚至连腾讯官方的文档都有这个问 ...

  9. Django项目中使用qq第三方登录。

    使用qq登录的前提是已经在qq互联官网创建网站应用并获取到QQ互联中网站应用的APP ID和APP KEY 1,建路由 # qq登录 path('loginQq/',qq.loginQq,name=' ...

随机推荐

  1. log4j2----JAVA日志打印

    注意:本篇文章是以log4j2.x 为例的,并不是log4j 1.x log4j 就是log for java  , log4j已经被移植到了C,C++,C#,Perl,Python和Ruby等语言中 ...

  2. 前端js框架引入管理bundle.js

    最先在ionic中看到bundle.js,,,然而它不是一个框架

  3. 【模板】tarjanLCA [2017年6月计划 学习tarjanLCA]

    P3379 [模板]最近公共祖先(LCA) 题目描述 如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先. 输入输出格式 输入格式: 第一行包含三个正整数N.M.S,分别表示树的结点个数.询 ...

  4. Laravel 某个字段更新失败的原因

    明明有这个title, 但是却始终更新不成功 原因是模型这里设置了可以更新的字段,所以直接用Db::table更新会成功

  5. 只需一步,DLA开启TableStore多元索引查询加速!

    一.背景介绍 Data Lake Analytics(简称DLA)在构建第一天就是支持直接关联分析Table Store(简称OTS)里的数据,实现存储计算分离架构,满足用户基于SQL接口分析Tabl ...

  6. Vue--由自动获取焦点引出的DOM、mounted、自定义指令

    一.自动获取焦点的DOM实现 <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  7. margin负值5种应用

    最近做的项目中经常会用到margin的负值,这里就总结一下关于margin负值的5种使用及相关bug的解决. 1. 在流动性布局中的应用 如WordPress的两栏式不固定布局就是使用margin负值 ...

  8. springboot整合neo4j

    刚开始按网上博客搭建 spring boot 和 neo4j一直报sessionFactory找不到,直到下载了spring-data-neo4j的实例demo对比才搭建成功,而且用户名是neo4j, ...

  9. 用Direct2D和DWM来做简单的动画效果

    原文:用Direct2D和DWM来做简单的动画效果 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sunnyloves/article/detail ...

  10. 【POJ 3294】Life Forms

    [链接]h在这里写链接 [题意] 给你n个字符串. 让你找最长的字符串s; 这个s在超过一半的子串里面都有出现过且长度大于n/2; 如果有多个,输出多行. (按字典序输出) 也没说会不会出现大写. [ ...