Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
黄先生-?
JustAuth
提交
9941ce7e
J
JustAuth
项目概览
黄先生-?
/
JustAuth
与 Fork 源项目一致
Fork自
justauth / JustAuth
通知
1
Star
1
Fork
0
代码
文件
提交
分支
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9941ce7e
编写于
6月 26, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://gitee.com/yadong.zhang/JustAuth
上级
4f594a41
b9268f29
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
11 deletion
+24
-11
README.md
README.md
+3
-3
pom.xml
pom.xml
+1
-1
src/main/java/me/zhyd/oauth/config/AuthConfig.java
src/main/java/me/zhyd/oauth/config/AuthConfig.java
+7
-0
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+4
-2
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
+6
-5
update.md
update.md
+3
-0
未找到文件。
README.md
浏览文件 @
9941ce7e
...
...
@@ -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.7.
0
-blue.svg"
></img>
<img
src=
"https://img.shields.io/badge/Maven Central-1.7.
1
-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>
...
...
@@ -68,7 +68,7 @@ JustAuth,如你所见,它仅仅是一个**第三方授权登录**的**工具
<dependency>
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.7.
0
</version>
<version>
1.7.
1
</version>
</dependency>
```
-
调用api
...
...
@@ -109,7 +109,7 @@ authRequest.login("code");
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/taobao.png"
width=
"20"
>
|
[
AuthTaobaoRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthTaobaoRequest.java
)
|
<a
href=
"https://open.taobao.com/doc.htm?spm=a219a.7386797.0.0.4e00669acnkQy6&source=search&docId=105590&docType=1"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/google.png"
width=
"20"
>
|
[
AuthGoogleRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthGoogleRequest.java
)
|
<a
href=
"https://developers.google.com/identity/protocols/OpenIDConnect"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/facebook.png"
width=
"20"
>
|
[
AuthFacebookRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthFacebookRequest.java
)
|
<a
href=
"https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png"
width=
"20"
>
|
[
AuthDouyinRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
)
|
<a
href=
"https://www.douyin.com/platform/doc"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/douyin.png"
width=
"20"
>
|
[
AuthDouyinRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
)
|
<a
href=
"https://www.douyin.com/platform/doc
/m-2-1-1
"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/linkedin.png"
width=
"20"
>
|
[
AuthLinkedinRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthLinkedinRequest.java
)
|
<a
href=
"https://docs.microsoft.com/zh-cn/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/microsoft.png"
width=
"20"
>
|
[
AuthMicrosoftRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMicrosoftRequest.java
)
|
<a
href=
"https://docs.microsoft.com/zh-cn/graph/auth/"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/mi.png"
width=
"20"
>
|
[
AuthMiRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
)
|
<a
href=
"https://dev.mi.com/console/doc/detail?pId=711"
target=
"_blank"
>
参考文档
</a>
|
...
...
pom.xml
浏览文件 @
9941ce7e
...
...
@@ -6,7 +6,7 @@
<groupId>
me.zhyd.oauth
</groupId>
<artifactId>
JustAuth
</artifactId>
<version>
1.7.
0
</version>
<version>
1.7.
1
</version>
<name>
JustAuth
</name>
<url>
https://gitee.com/yadong.zhang/JustAuth
</url>
...
...
src/main/java/me/zhyd/oauth/config/AuthConfig.java
浏览文件 @
9941ce7e
...
...
@@ -35,4 +35,11 @@ public class AuthConfig {
* 支付宝公钥:当选择支付宝登录时,该值可用
*/
private
String
alipayPublicKey
;
/**
* 是否需要申请unionid,目前只针对qq登录
* 注:qq授权登录时,获取unionid需要单独发送邮件申请权限。如果个人开发者账号中申请了该权限,可以将该值置为true,在获取openId时就会同步获取unionId
* 参考链接:http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D
*/
private
boolean
unionId
;
}
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
浏览文件 @
9941ce7e
...
...
@@ -85,7 +85,7 @@ public class AuthQqRequest extends BaseAuthRequest {
private
String
getOpenId
(
AuthToken
authToken
)
{
String
accessToken
=
authToken
.
getAccessToken
();
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getQqOpenidUrl
(
"https://graph.qq.com/oauth2.0/me"
,
accessToken
))
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getQqOpenidUrl
(
"https://graph.qq.com/oauth2.0/me"
,
accessToken
,
config
.
isUnionId
()
))
.
execute
();
if
(
response
.
isOk
())
{
String
body
=
response
.
body
();
...
...
@@ -97,7 +97,9 @@ public class AuthQqRequest extends BaseAuthRequest {
throw
new
AuthException
(
object
.
get
(
"error"
)
+
":"
+
object
.
get
(
"error_description"
));
}
authToken
.
setOpenId
(
object
.
getString
(
"openid"
));
authToken
.
setUnionId
(
object
.
getString
(
"unionid"
));
if
(
object
.
containsKey
(
"unionid"
))
{
authToken
.
setUnionId
(
object
.
getString
(
"unionid"
));
}
return
StringUtils
.
isEmpty
(
authToken
.
getUnionId
())
?
authToken
.
getOpenId
()
:
authToken
.
getUnionId
();
}
...
...
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
浏览文件 @
9941ce7e
...
...
@@ -58,7 +58,7 @@ public class UrlBuilder {
private
static
final
String
QQ_ACCESS_TOKEN_PATTERN
=
"{0}?client_id={1}&client_secret={2}&grant_type=authorization_code&code={3}&redirect_uri={4}"
;
private
static
final
String
QQ_USER_INFO_PATTERN
=
"{0}?oauth_consumer_key={1}&access_token={2}&openid={3}"
;
private
static
final
String
QQ_AUTHORIZE_PATTERN
=
"{0}?client_id={1}&response_type=code&redirect_uri={2}&state={3}"
;
private
static
final
String
QQ_OPENID_PATTERN
=
"{0}?access_token={1}&unionid=
1
"
;
private
static
final
String
QQ_OPENID_PATTERN
=
"{0}?access_token={1}&unionid=
{2}
"
;
private
static
final
String
WECHAT_AUTHORIZE_PATTERN
=
"{0}?appid={1}&redirect_uri={2}&response_type=code&scope=snsapi_login&state={3}#wechat_redirect"
;
private
static
final
String
WECHAT_ACCESS_TOKEN_PATTERN
=
"{0}?appid={1}&secret={2}&code={3}&grant_type=authorization_code"
;
...
...
@@ -438,12 +438,13 @@ public class UrlBuilder {
/**
* 获取qq授权地址
*
* @param url 获取qqopenid的api接口地址
* @param token qq 应用授权的token
* @param url 获取qqopenid的api接口地址
* @param token qq 应用授权的token
* @param unionid 是否需要获取unionid,默认为false。注:获取unionid需要单独发送邮件申请权限,请个人视情况而定。参考链接:http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D
* @return full url
*/
public
static
String
getQqOpenidUrl
(
String
url
,
String
token
)
{
return
MessageFormat
.
format
(
QQ_OPENID_PATTERN
,
url
,
token
);
public
static
String
getQqOpenidUrl
(
String
url
,
String
token
,
boolean
unionid
)
{
return
MessageFormat
.
format
(
QQ_OPENID_PATTERN
,
url
,
token
,
unionid
?
1
:
0
);
}
/**
...
...
update.md
浏览文件 @
9941ce7e
### 2019/06/25
qq授权登录时,需要获取
`openId`
作为
`uuid`
,在
`1.6.1-beta`
和
`1.7.0`
版本中,引入了
`unionId`
这一属性。获取
`unionid`
需要单独向qq团队
**发送邮件**
申请权限,鉴于这一申请权限的步骤比较麻烦(需要填写的内容比较多),所以在
`AuthConfig`
中增加了一个
`unionId`
属性,当为
**true**
时才会获取unionid,当为false时只获取openId。如果你需要该功能, 则在自行申请了相关权限后,将该属性置为true即可。关于unionId的参考链接:
[
UnionID介绍
](
http://wiki.connect.qq.com/unionid%E4%BB%8B%E7%BB%8D
)
### 2019/06/19
1.
合并
[
xkcoding
](
https://github.com/xkcoding
)
提交的
[
PR
](
https://github.com/zhangyd-c/JustAuth/pull/14
)
,重构了部分代码,jar包由原来的
`130+kb`
优化到现在的
`110+kb`
2.
合并
[
skqing
](
https://gitee.com/skqing
)
提交的
[
PR
](
https://gitee.com/yadong.zhang/JustAuth/pulls/3
)
, 解决抖音登录失败问题
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录