Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_48050326
JustAuth
提交
1c1d2dc9
J
JustAuth
项目概览
weixin_48050326
/
JustAuth
与 Fork 源项目一致
Fork自
justauth / JustAuth
通知
1
Star
0
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,发现更多精彩内容 >>
提交
1c1d2dc9
编写于
6月 19, 2019
作者:
智布道
👁
提交者:
Gitee
6月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
!2 修复最近提出一些问题和BUG
Merge pull request !2 from skqing/master
上级
82358cbd
dcf5f30e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
22 deletion
+35
-22
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
+5
-1
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
+2
-4
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
+2
-4
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
+2
-4
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
+23
-8
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
+1
-1
未找到文件。
src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
浏览文件 @
1c1d2dc9
...
...
@@ -69,12 +69,16 @@ public class AuthAlipayRequest extends BaseAuthRequest {
}
String
province
=
response
.
getProvince
(),
city
=
response
.
getCity
();
String
location
=
province
;
if
(!
StringUtils
.
isEmpty
(
city
))
{
location
=
location
+
"-"
+
city
;
}
return
AuthUser
.
builder
()
.
uuid
(
response
.
getUserId
())
.
username
(
StringUtils
.
isEmpty
(
response
.
getUserName
())
?
response
.
getNickName
()
:
response
.
getUserName
())
.
nickname
(
response
.
getNickName
())
.
avatar
(
response
.
getAvatar
())
.
location
(
String
.
format
(
"%s %s"
,
StringUtils
.
isEmpty
(
province
)
?
""
:
province
,
StringUtils
.
isEmpty
(
city
)
?
""
:
city
)
)
.
location
(
location
)
.
gender
(
AuthUserGender
.
getRealGender
(
response
.
getGender
()))
.
token
(
authToken
)
.
source
(
AuthSource
.
ALIPAY
)
...
...
src/main/java/me/zhyd/oauth/request/AuthDingTalkRequest.java
浏览文件 @
1c1d2dc9
...
...
@@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthDingTalkErrorCode
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.utils.GlobalAuthUtil
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
...
@@ -58,6 +55,7 @@ public class AuthDingTalkRequest extends BaseAuthRequest {
.
uuid
(
object
.
getString
(
"unionid"
))
.
nickname
(
object
.
getString
(
"nick"
))
.
username
(
object
.
getString
(
"nick"
))
.
gender
(
AuthUserGender
.
UNKNOW
)
.
source
(
AuthSource
.
DINGTALK
)
.
token
(
token
)
.
build
();
...
...
src/main/java/me/zhyd/oauth/request/AuthDouyinRequest.java
浏览文件 @
1c1d2dc9
...
...
@@ -5,10 +5,7 @@ import cn.hutool.http.HttpResponse;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.utils.UrlBuilder
;
...
...
@@ -45,6 +42,7 @@ public class AuthDouyinRequest extends BaseAuthRequest {
.
username
(
userInfoObject
.
getString
(
"nickname"
))
.
nickname
(
userInfoObject
.
getString
(
"nickname"
))
.
avatar
(
userInfoObject
.
getString
(
"avatar"
))
.
gender
(
AuthUserGender
.
UNKNOW
)
.
token
(
authToken
)
.
source
(
AuthSource
.
DOUYIN
)
.
build
();
...
...
src/main/java/me/zhyd/oauth/request/AuthMiRequest.java
浏览文件 @
1c1d2dc9
...
...
@@ -6,10 +6,7 @@ import cn.hutool.http.HttpResponse;
import
com.alibaba.fastjson.JSONObject
;
import
me.zhyd.oauth.config.AuthConfig
;
import
me.zhyd.oauth.exception.AuthException
;
import
me.zhyd.oauth.model.AuthResponse
;
import
me.zhyd.oauth.model.AuthSource
;
import
me.zhyd.oauth.model.AuthToken
;
import
me.zhyd.oauth.model.AuthUser
;
import
me.zhyd.oauth.model.*
;
import
me.zhyd.oauth.utils.UrlBuilder
;
import
java.text.MessageFormat
;
...
...
@@ -74,6 +71,7 @@ public class AuthMiRequest extends BaseAuthRequest {
.
nickname
(
user
.
getString
(
"miliaoNick"
))
.
avatar
(
user
.
getString
(
"miliaoIcon"
))
.
email
(
user
.
getString
(
"mail"
))
.
gender
(
AuthUserGender
.
UNKNOW
)
.
token
(
authToken
)
.
source
(
AuthSource
.
MI
)
.
build
();
...
...
src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
浏览文件 @
1c1d2dc9
...
...
@@ -48,8 +48,15 @@ public class AuthQqRequest extends BaseAuthRequest {
@Override
protected
AuthUser
getUserInfo
(
AuthToken
authToken
)
{
String
accessToken
=
authToken
.
getAccessToken
();
String
openId
=
this
.
getOpenId
(
accessToken
);
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getQqUserInfoUrl
(
config
.
getClientId
(),
accessToken
,
openId
))
String
openIdStr
=
this
.
getOpenId
(
accessToken
);
String
[]
openIdArr
=
openIdStr
.
split
(
"\\|"
);
authToken
.
setOpenId
(
openIdArr
[
0
]);
String
uuid
=
authToken
.
getOpenId
();
if
(
openIdArr
.
length
==
2
)
{
uuid
=
openIdArr
[
1
];
}
HttpResponse
response
=
HttpRequest
.
get
(
UrlBuilder
.
getQqUserInfoUrl
(
config
.
getClientId
(),
accessToken
,
authToken
.
getOpenId
()))
.
execute
();
JSONObject
object
=
JSONObject
.
parseObject
(
response
.
body
());
if
(
object
.
getIntValue
(
"ret"
)
!=
0
)
{
...
...
@@ -64,7 +71,7 @@ public class AuthQqRequest extends BaseAuthRequest {
.
nickname
(
object
.
getString
(
"nickname"
))
.
avatar
(
avatar
)
.
location
(
object
.
getString
(
"province"
)
+
"-"
+
object
.
getString
(
"city"
))
.
uuid
(
openI
d
)
.
uuid
(
uui
d
)
.
gender
(
AuthUserGender
.
getRealGender
(
object
.
getString
(
"gender"
)))
.
token
(
authToken
)
.
source
(
AuthSource
.
QQ
)
...
...
@@ -78,13 +85,21 @@ public class AuthQqRequest extends BaseAuthRequest {
String
body
=
response
.
body
();
String
removePrefix
=
StrUtil
.
replace
(
body
,
"callback("
,
""
);
String
removeSuffix
=
StrUtil
.
replace
(
removePrefix
,
");"
,
""
);
String
openId
=
StrUtil
.
trim
(
removeSuffix
);
JSONObject
object
=
JSONObject
.
parseObject
(
openId
);
String
jsonStr
=
StrUtil
.
trim
(
removeSuffix
);
JSONObject
object
=
JSONObject
.
parseObject
(
jsonStr
);
StringBuffer
sb
=
new
StringBuffer
();
if
(
object
.
containsKey
(
"openid"
))
{
return
object
.
getString
(
"openid"
);
sb
.
append
(
object
.
getString
(
"openid"
));
sb
.
append
(
"|"
);
}
else
{
throw
new
AuthException
(
"Invalid openId"
);
}
throw
new
AuthException
(
"Invalid openId"
);
if
(
object
.
containsKey
(
"unionid"
))
{
sb
.
append
(
object
.
getString
(
"unionid"
));
}
return
sb
.
toString
();
}
throw
new
AuthException
(
"Invalid openId"
);
throw
new
AuthException
(
"request error"
);
}
}
src/main/java/me/zhyd/oauth/utils/UrlBuilder.java
浏览文件 @
1c1d2dc9
...
...
@@ -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}"
;
private
static
final
String
QQ_OPENID_PATTERN
=
"{0}?access_token={1}
&unionid=1
"
;
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"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录