From 3cd9501ed06a8b26e34218869060c7eb9996f304 Mon Sep 17 00:00:00 2001 From: "Bostin.wang" Date: Fri, 30 Dec 2022 14:50:30 +0800 Subject: [PATCH] add lark (#257) Co-authored-by: bostin.wang --- README.md | 35 +++++++++++++++++++++++++++++++++-- README_EN.md | 33 ++++++++++++++++++++++++++++++++- src/Providers/Lark.php | 12 ++++++++++++ src/SocialiteManager.php | 1 + 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 src/Providers/Lark.php diff --git a/README.md b/README.md index c4f4a9b..e25ea5a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Socialite 是一个 [OAuth2](https://oauth.net/2/) 认证工具。 它的灵感 [![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue) -该工具现已支持平台有:Facebook,Github,Google,Linkedin,Outlook,QQ,TAPD,支付宝,淘宝,百度,钉钉,微博,微信,抖音,飞书,豆瓣,企业微信,腾讯云,Line,Gitee,Coding。 +该工具现已支持平台有:Facebook,Github,Google,Linkedin,Outlook,QQ,TAPD,支付宝,淘宝,百度,钉钉,微博,微信,抖音,飞书,Lark,豆瓣,企业微信,腾讯云,Line,Gitee,Coding。 如果你喜欢我的项目并想支持我,[点击这里 :heart:](https://github.com/sponsors/overtrue) @@ -381,6 +381,36 @@ $feishuDriver->withInternalAppMode()->userFromCode('here is code'); $feishuDriver->withDefaultMode()->withAppTicket('app_ticket')->userFromCode('here is code'); ``` +### [Lark](https://open.larksuite.com/document/ukTMukTMukTM/uITNz4iM1MjLyUzM) + +通过一些简单的方法配置 app_ticket 就能使用内部应用模式 + +```php +$config = [ + 'lark' => [ + // or 'app_id' + 'client_id' => 'your app id', + + // or 'app_secret' + 'client_secret' => 'your app secret', + + // or 'redirect_url' + 'redirect' => 'redirect URL', + + // 如果你想使用使用内部应用的方式获取 app_access_token + // 对这个键设置了 'internal' 值那么你已经开启了内部应用模式 + 'app_mode' => 'internal' + ] +]; + +$socialite = new SocialiteManager($config); + +$larkDriver = $socialite->create('lark'); + +$larkDriver->withInternalAppMode()->userFromCode('here is code'); +$larkDriver->withDefaultMode()->withAppTicket('app_ticket')->userFromCode('here is code'); +``` + ### [淘宝](https://open.taobao.com/doc.htm?docId=102635&docType=1&source=search) 其他配置与其他平台的一样,你能选择你想要展示的重定向页面类型通过使用 `withView()` @@ -614,6 +644,7 @@ $user = $socialite->userFromToken($accessToken); - [豆瓣 - OAuth 2.0 授权机制说明](http://developers.douban.com/wiki/?title=oauth2) - [抖音 - 网站应用开发指南](http://open.douyin.com/platform/doc) - [飞书 - 授权说明](https://open.feishu.cn/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM) +- [Lark - 授权说明](https://open.larksuite.com/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM) - [Tapd - 用户授权说明](https://www.tapd.cn/help/show#1120003271001000093) - [Line - OAuth 2.0](https://developers.line.biz/en/docs/line-login/integrate-line-login/) - [Gitee - OAuth文档](https://gitee.com/api/v5/oauth_doc#/) @@ -628,4 +659,4 @@ $user = $socialite->userFromToken($accessToken); # License -MIT \ No newline at end of file +MIT diff --git a/README_EN.md b/README_EN.md index c0ec6e8..c653435 100644 --- a/README_EN.md +++ b/README_EN.md @@ -8,7 +8,7 @@ Socialite is an [OAuth2](https://oauth.net/2/) Authentication tool. It is inspi [![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue) -This tool now supports platforms such as Facebook, GitHub, Google, Figma, LinkedIn, Outlook, QQ, Tapd, Alipay, Taobao, Baidu, DingTalk, Weibo, WeChat, Douyin, Feishu, Douban, WeWork, Tencent Cloud, Line, Gitee and Coding. +This tool now supports platforms such as Facebook, GitHub, Google, Figma, LinkedIn, Outlook, QQ, Tapd, Alipay, Taobao, Baidu, DingTalk, Weibo, WeChat, Douyin, Feishu, Lark, Douban, WeWork, Tencent Cloud, Line, Gitee and Coding. 如果你喜欢我的项目并想支持我,[点击这里 :heart:](https://github.com/sponsors/overtrue) @@ -365,6 +365,36 @@ $feishuDriver->withInternalAppMode()->userFromCode('here is code'); $feishuDriver->withDefaultMode()->withAppTicket('app_ticket')->userFromCode('here is code'); ``` +### [Lark](https://open.larksuite.com/document/ukTMukTMukTM/uITNz4iM1MjLyUzM) + +Some simple way to use by internal app mode and config app_ticket. + +```php +$config = [ + 'lark' => [ + // or 'app_id' + 'client_id' => 'your app id', + + // or 'app_secret' + 'client_secret' => 'your app secret', + + // or 'redirect_url' + 'redirect' => 'redirect URL', + + // if you want to use internal way to get app_access_token + // set this key by 'internal' then you already turn on the internal app mode + 'app_mode' => 'internal' + ] +]; + +$socialite = new SocialiteManager($config); + +$larkDriver = $socialite->create('lark'); + +$larkDriver->withInternalAppMode()->userFromCode('here is code'); +$larkDriver->withDefaultMode()->withAppTicket('app_ticket')->userFromCode('here is code'); +``` + ### [Taobao](https://open.taobao.com/doc.htm?docId=102635&docType=1&source=search) You can choose the form you want display by using `withView()`. @@ -593,6 +623,7 @@ $user = $socialite->userFromToken($accessToken); - [豆瓣 - OAuth 2.0 授权机制说明](http://developers.douban.com/wiki/?title=oauth2) - [抖音 - 网站应用开发指南](http://open.douyin.com/platform/doc) - [飞书 - 授权说明](https://open.feishu.cn/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM) +- [Lark - 授权说明](https://open.larksuite.com/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM) - [Tapd - 用户授权说明](https://www.tapd.cn/help/show#1120003271001000093) - [Line - OAuth 2.0](https://developers.line.biz/en/docs/line-login/integrate-line-login/) - [Gitee - OAuth文档](https://gitee.com/api/v5/oauth_doc#/) diff --git a/src/Providers/Lark.php b/src/Providers/Lark.php new file mode 100644 index 0000000..e19192d --- /dev/null +++ b/src/Providers/Lark.php @@ -0,0 +1,12 @@ + Providers\GitHub::class, Providers\Gitee::NAME => Providers\Gitee::class, Providers\Google::NAME => Providers\Google::class, + Providers\Lark::NAME => Providers\Lark::class, Providers\Line::NAME => Providers\Line::class, Providers\Linkedin::NAME => Providers\Linkedin::class, Providers\OpenWeWork::NAME => Providers\OpenWeWork::class,