# php_thirdparty_oauth
**Repository Path**: pltrue/php_thirdparty_oauth
## Basic Information
- **Project Name**: php_thirdparty_oauth
- **Description**: 这是一个全面的php第三方授权登录扩展包 目前支持github、gitee、微博、gitlab、qq、microsoft 微信、小米、google、华为、line、抖音 等第三方登录
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: https://pltrue.top/article/28
- **GVP Project**: No
## Statistics
- **Stars**: 4
- **Forks**: 2
- **Created**: 2020-09-16
- **Last Updated**: 2021-11-24
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
ThirdpartyOauth
[](https://travis-ci.org/pl1998/thirdparty_oauth)

这是一个社会化登录的第三方登录扩展包
## 安装
使用 composer 安装:
```shell
$ composer require pltrue/thirdparty_oauth "v1.7"
```
## 贡献
你可以通过以下三种方式做出贡献:
1. bug反馈 [issue tracker](https://github.com/pl1998/thirdparty_oauth/issues).
2. 回答问题或修复错误 [issue tracker](https://github.com/pl1998/thirdparty_oauth/issues).
3. 贡献新特性或更新wiki。
## 目前支持第三方登录
* 1.QQ(app/h5/web)
* 2.微信(web扫码)
* 3.微博(app/h5/web)
* 4.小米(web/h5)
* 5.抖音
* 6.世纪互联(微软)
* 7.微软
* 8.gitee
* 9.github
* 10.gitlab
* 11.google
* 12.line
## 贡献者🎉、以及合并日志
| 日期 | 更新级别 | 更新内容 | 贡献者 | 当前状态 |
| ------| -------- | --------- | ---- | ---- |
| 2020-12-06| fix 、feat | 新增`Microsoft`登录 修复微信、QQ的bug | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-08| feat | 新增`小米账户`登录 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-09| feat | 新增`google账户`登录 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-10| feat | 新增`华为账户`登录 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-11| fix | qq统一使用json接口 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-12| feat | 新增`抖音账户`登录 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-13| feat | 新增`Line账户`登录 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-29| fix | 增加兼容支付宝qq app混合应用兼容 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-29| feat | 新增`京东账户`登录 | [742481030](https://github.com/742481030) | 已合并到master分支 |
| 2020-12-29| fix | 兼容laravel7* | [pl1998](https://github.com/pl1998) | 已合并到master分支 |
| 2021-04-19| feat | 兼容laravel8* 支持laravel发布配置文件 | [pl1998](https://github.com/pl1998) | 已合并到master分支 |
## 如何申请应用授权?
* [github应用创建地址](https://github.com/settings/developers)
* [gitee应用创建地址](https://gitee.com/oauth/applications)
* [gitlab应用创建地址](https://gitlab.com/oauth/applications)
* [微博应用创建地址](https://open.weibo.com/)
* [microcoft应用创建地址](https://azure.com/)
* [QQ互联创建地址](https://connect.qq.com/index.html)
* [小米应用](https://dev.mi.com/console/)
* [google应用](https://console.developers.google.com)
* [京东应用](https://jos.jd.com/)
##### 参数说明
> redirect_url 回调地址将使用方法写到回调接口即可 获取到用户的一些基础信息
> client_id 应用授权id
> client_secret 应用授权key
> 所有支持平台的类型 `github` `gitee` `gitlab` `weibo` `qq` `weixin` `alipay` `microsoft` 配置文件下标一致
##### 建议
> 前后端分离下建议前端直接请求授权接口,后端负责回调接口即可
#### 安装
```shell script
composer require pltrue/thirdparty_oauth "v1.7"
```
#### 发布配置
```shell script
php artisan vendor:publish --tag=oauth
```
### 简单使用
* 授权方法
````php
$api = new SocialiteAuth(config('oauth.github'));
return $api->redirect('github');
````
*回调方法
```php
public function githubCallBack()
{
$auth = new SocialiteAuth(config('oauth.github'));
$user = $auth->driver('github')->user();
$users = User::query()->where('oauth_id',$user->id)->first();
if(!$users){
$users= User::query()->create([
'name'=> empty($user->name) ?? $user->login,
'email'=>$user->email,
'avatar'=>$user->avatar_url,
'oauth_id'=>$user->id,
'bound_oauth'=>1
]);
}
return $this->respondWithToken($users);
}
```
## 返回示例

## License
MIT