Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
justauth
JustAuth
提交
66c7455d
J
JustAuth
项目概览
justauth
/
JustAuth
1 年多 前同步成功
通知
394
Star
15212
Fork
2708
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JustAuth
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
66c7455d
编写于
9月 06, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
集成美团,待发布1.12.0
上级
055807d7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
154 addition
and
8 deletion
+154
-8
README.en-US.md
README.en-US.md
+4
-2
README.md
README.md
+5
-3
docs/README.md
docs/README.md
+3
-2
pom.xml
pom.xml
+1
-1
src/main/java/me/zhyd/oauth/config/AuthSource.java
src/main/java/me/zhyd/oauth/config/AuthSource.java
+27
-0
src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java
src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java
+114
-0
未找到文件。
README.en-US.md
浏览文件 @
66c7455d
...
...
@@ -6,7 +6,7 @@
</p>
<p
align=
"center"
>
<a
target=
"_blank"
href=
"https://search.maven.org/search?q=JustAuth"
>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
1
.0-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
2
.0-blue.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"
>
<img
src=
"https://img.shields.io/apm/l/vim-mode.svg?color=yellow"
></img>
...
...
@@ -15,7 +15,7 @@
<img
src=
"https://img.shields.io/badge/JDK-1.8+-green.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://apidoc.gitee.com/yadong.zhang/JustAuth/"
title=
"API文档"
>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
1
.0-orange.svg"
></img>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
2
.0-orange.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://docs.justauth.whnb.wang"
title=
"参考文档"
>
<img
src=
"https://img.shields.io/badge/Docs-latest-blueviolet.svg"
></img>
...
...
@@ -66,6 +66,7 @@
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png"
width=
"20"
></td>
</tr>
</table>
</center>
...
...
@@ -150,6 +151,7 @@ authRequest.login(callback);
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
>
|
[
AuthWeChatEnterpriseRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java
)
|
<a
href=
"https://open.work.weixin.qq.com/api/doc#90000/90135/90664"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
>
|
[
AuthKujialeRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
)
|
<a
href=
"https://open.kujiale.com/open/apps/2/docs?doc_id=95"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
>
|
[
AuthGitlabRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
)
|
<a
href=
"https://docs.gitlab.com/ee/api/oauth2.html"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png"
width=
"20"
>
|
[
AuthMeituanRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java
)
|
<a
href=
"http://open.waimai.meituan.com/openapi_docs/oauth/"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
...
...
README.md
浏览文件 @
66c7455d
...
...
@@ -6,7 +6,7 @@
</p>
<p
align=
"center"
>
<a
target=
"_blank"
href=
"https://search.maven.org/search?q=JustAuth"
>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
1
.0-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
2
.0-blue.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"
>
<img
src=
"https://img.shields.io/apm/l/vim-mode.svg?color=yellow"
></img>
...
...
@@ -15,7 +15,7 @@
<img
src=
"https://img.shields.io/badge/JDK-1.8+-green.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://apidoc.gitee.com/yadong.zhang/JustAuth/"
title=
"API文档"
>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
1
.0-orange.svg"
></img>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
2
.0-orange.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://docs.justauth.whnb.wang"
title=
"参考文档"
>
<img
src=
"https://img.shields.io/badge/Docs-latest-blueviolet.svg"
></img>
...
...
@@ -66,6 +66,7 @@
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
></td>
<td
align=
"center"
width=
"200"
><img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png"
width=
"20"
></td>
</tr>
</table>
</center>
...
...
@@ -93,7 +94,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.1
1
.0
</version>
<version>
1.1
2
.0
</version>
</dependency>
```
-
调用api
...
...
@@ -160,6 +161,7 @@ authRequest.login(callback);
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechat.png"
width=
"20"
>
|
[
AuthWeChatEnterpriseRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthWeChatEnterpriseRequest.java
)
|
<a
href=
"https://open.work.weixin.qq.com/api/doc#90000/90135/90664"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
>
|
[
AuthKujialeRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
)
|
<a
href=
"https://open.kujiale.com/open/apps/2/docs?doc_id=95"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
>
|
[
AuthGitlabRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
)
|
<a
href=
"https://docs.gitlab.com/ee/api/oauth2.html"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png"
width=
"20"
>
|
[
AuthMeituanRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java
)
|
<a
href=
"http://open.waimai.meituan.com/openapi_docs/oauth/"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
_请知悉:经咨询CSDN官方客服得知,CSDN的授权开放平台已经下线。如果以前申请过的应用,可以继续使用,但是不再支持申请新的应用。so, 本项目中的CSDN登录只能针对少部分用户使用了_
...
...
docs/README.md
浏览文件 @
66c7455d
...
...
@@ -9,7 +9,7 @@
</p>
<p
align=
"center"
>
<a
target=
"_blank"
href=
"https://search.maven.org/search?q=JustAuth"
>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
1
.0-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.1
2
.0-blue.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://gitee.com/yadong.zhang/JustAuth/blob/master/LICENSE"
>
<img
src=
"https://img.shields.io/apm/l/vim-mode.svg?color=yellow"
></img>
...
...
@@ -18,7 +18,7 @@
<img
src=
"https://img.shields.io/badge/JDK-1.8+-green.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://apidoc.gitee.com/yadong.zhang/JustAuth/"
title=
"API文档"
>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
1
.0-orange.svg"
></img>
<img
src=
"https://img.shields.io/badge/Api Docs-1.1
2
.0-orange.svg"
></img>
</a>
<a
target=
"_blank"
href=
"https://docs.justauth.whnb.wang"
title=
"参考文档"
>
<img
src=
"https://img.shields.io/badge/Docs-latest-blueviolet.svg"
></img>
...
...
@@ -90,6 +90,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/csdn.png"
width=
"20"
>
|
[
AuthCsdnRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
| 无 |
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/kujiale.png"
width=
"20"
>
|
[
AuthKujialeRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthKujialeRequest.java
)
|
<a
href=
"https://open.kujiale.com/open/apps/2/docs?doc_id=95"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/gitlab.png"
width=
"20"
>
|
[
AuthGitlabRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGitlabRequest.java
)
|
<a
href=
"https://docs.gitlab.com/ee/api/oauth2.html"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/meituan.png"
width=
"20"
>
|
[
AuthMeituanRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java
)
|
<a
href=
"http://open.waimai.meituan.com/openapi_docs/oauth/"
target=
"_blank"
>
参考文档
</a>
|
## 快速开始
...
...
pom.xml
浏览文件 @
66c7455d
...
...
@@ -6,7 +6,7 @@
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.1
1
.0
</version>
<version>
1.1
2
.0
</version>
<name>
JustAuth
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
...
...
src/main/java/me/zhyd/oauth/config/AuthSource.java
浏览文件 @
66c7455d
...
...
@@ -616,6 +616,33 @@ public enum AuthSource {
public
String
userInfo
()
{
return
"https://gitlab.com/api/v4/user"
;
}
},
/**
* 美团
*
* @since 1.12.0
*/
MEITUAN
{
@Override
public
String
authorize
()
{
return
"https://openapi.waimai.meituan.com/oauth/authorize"
;
}
@Override
public
String
accessToken
()
{
return
"https://openapi.waimai.meituan.com/oauth/access_token"
;
}
@Override
public
String
userInfo
()
{
return
"https://openapi.waimai.meituan.com/oauth/userinfo"
;
}
@Override
public
String
refresh
()
{
return
"https://openapi.waimai.meituan.com/oauth/refresh_token"
;
}
};
/**
...
...
src/main/java/me/zhyd/oauth/request/AuthMeituanRequest.java
0 → 100644
浏览文件 @
66c7455d
package
me.zhyd.oauth.request
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.cache.AuthStateCache
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.config.AuthSource
;
import
me.zhyd.oauth.enums.AuthResponseStatus
;
import
me.zhyd.oauth.enums.AuthUserGender
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthCallback
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.utils.UrlBuilder
;
/**
* 美团登录
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @since 1.12.0
*/
public
class
AuthMeituanRequest
extends
AuthDefaultRequest
{
public
AuthMeituanRequest
(
AuthConfig
config
)
{
super
(
config
,
AuthSource
.
MEITUAN
);
}
public
AuthMeituanRequest
(
AuthConfig
config
,
AuthStateCache
authStateCache
)
{
super
(
config
,
AuthSource
.
MEITUAN
,
authStateCache
);
}
@Override
protected
AuthToken
getAccessToken
(
AuthCallback
authCallback
)
{
HttpResponse
response
=
HttpRequest
.
post
(
source
.
accessToken
())
.
form
(
"app_id"
,
config
.
getClientId
())
.
form
(
"secret"
,
config
.
getClientSecret
())
.
form
(
"code"
,
authCallback
.
getCode
())
.
form
(
"grant_type"
,
"authorization_code"
)
.
execute
();
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
this
.
checkResponse
(
object
);
return
AuthToken
.
builder
()
.
accessToken
(
object
.
getString
(
"access_token"
))
.
refreshToken
(
object
.
getString
(
"refresh_token"
))
.
expireIn
(
object
.
getIntValue
(
"expires_in"
))
.
build
();
}
@Override
protected
AuthUser
getUserInfo
(
AuthToken
authToken
)
{
HttpResponse
response
=
HttpRequest
.
post
(
source
.
userInfo
())
.
form
(
"app_id"
,
config
.
getClientId
())
.
form
(
"secret"
,
config
.
getClientSecret
())
.
form
(
"access_token"
,
authToken
.
getAccessToken
())
.
execute
();
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
this
.
checkResponse
(
object
);
return
AuthUser
.
builder
()
.
uuid
(
object
.
getString
(
"openid"
))
.
username
(
object
.
getString
(
"nickname"
))
.
nickname
(
object
.
getString
(
"nickname"
))
.
avatar
(
object
.
getString
(
"avatar"
))
.
gender
(
AuthUserGender
.
UNKNOWN
)
.
token
(
authToken
)
.
source
(
source
)
.
build
();
}
@Override
public
AuthResponse
refresh
(
AuthToken
oldToken
)
{
HttpResponse
response
=
HttpRequest
.
post
(
source
.
accessToken
())
.
form
(
"app_id"
,
config
.
getClientId
())
.
form
(
"secret"
,
config
.
getClientSecret
())
.
form
(
"refresh_token"
,
oldToken
.
getRefreshToken
())
.
form
(
"grant_type"
,
"authorization_code"
)
.
execute
();
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
this
.
checkResponse
(
object
);
return
AuthResponse
.
builder
()
.
code
(
AuthResponseStatus
.
SUCCESS
.
getCode
())
.
data
(
AuthToken
.
builder
()
.
accessToken
(
object
.
getString
(
"access_token"
))
.
refreshToken
(
object
.
getString
(
"refresh_token"
))
.
expireIn
(
object
.
getIntValue
(
"expires_in"
))
.
build
())
.
build
();
}
private
void
checkResponse
(
JSONObject
object
)
{
if
(
object
.
containsKey
(
"error_code"
))
{
throw
new
AuthException
(
object
.
getString
(
"erroe_msg"
));
}
}
@Override
public
String
authorize
(
String
state
)
{
return
UrlBuilder
.
fromBaseUrl
(
source
.
authorize
())
.
queryParam
(
"response_type"
,
"code"
)
.
queryParam
(
"app_id"
,
config
.
getClientId
())
.
queryParam
(
"redirect_uri"
,
config
.
getRedirectUri
())
.
queryParam
(
"state"
,
getRealState
(
state
))
.
queryParam
(
"scope"
,
""
)
.
build
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录