Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
justauth
JustAuth
提交
79574a66
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看板
提交
79574a66
编写于
5月 18, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
👽
注释、文档
上级
6186236a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
4 deletion
+47
-4
README.md
README.md
+1
-1
src/main/java/me/zhyd/oauth/config/AuthConfig.java
src/main/java/me/zhyd/oauth/config/AuthConfig.java
+11
-0
src/main/java/me/zhyd/oauth/consts/ApiUrl.java
src/main/java/me/zhyd/oauth/consts/ApiUrl.java
+16
-1
src/main/java/me/zhyd/oauth/model/AuthUserGender.java
src/main/java/me/zhyd/oauth/model/AuthUserGender.java
+6
-2
src/test/java/me/zhyd/oauth/AuthRequestTest.java
src/test/java/me/zhyd/oauth/AuthRequestTest.java
+13
-0
未找到文件。
README.md
浏览文件 @
79574a66
...
...
@@ -103,7 +103,7 @@ authRequest.login("code");
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/alipay.png"
width=
"20"
>
|
[
AuthAlipayRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthAlipayRequest.java
)
|
<a
href=
"https://alipay.open.taobao.com/docs/doc.htm?spm=a219a.7629140.0.0.336d4b70GUKXOl&treeId=193&articleId=105809&docType=1"
target=
"_blank"
>
参考文档
</a>
|
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/qq.png"
width=
"20"
>
|
[
AuthQqRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthQqRequest.java
)
|
<a
href=
"http://wiki.connect.qq.com/"
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
)
| 待续 |
|
<img
src=
"https://gitee.com/yadong.zhang/static/raw/master/JustAuth/wechats.png"
width=
"20"
>
|
[
AuthWeChatRequest
](
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/wechats.png"
width=
"20"
>
|
[
AuthWeChatRequest
](
https://gitee.com/yadong.zhang/JustAuth/blob/master/src/main/java/me/zhyd/oauth/request/AuthCsdnRequest.java
)
|
<a
href=
"https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN"
target=
"_blank"
>
参考文档
</a>
|
## 后续开发计划
...
...
src/main/java/me/zhyd/oauth/config/AuthConfig.java
浏览文件 @
79574a66
...
...
@@ -6,6 +6,8 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
/**
* JustAuth配置类
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @since 1.8
...
...
@@ -15,8 +17,17 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public
class
AuthConfig
{
/**
* 客户端id:对应个平台的appKey
*/
private
String
clientId
;
/**
* 客户端Secret:对应个平台的appSecret
*/
private
String
clientSecret
;
/**
* 登录成功后的回调地址
*/
...
...
src/main/java/me/zhyd/oauth/consts/ApiUrl.java
浏览文件 @
79574a66
...
...
@@ -356,18 +356,33 @@ public enum ApiUrl {
@Override
public
String
refresh
()
{
return
"https://api.weixin.qq.com/sns/oauth2/refresh_token"
;
return
"https://api.weixin.qq.com/sns/oauth2/refresh_token"
;
}
};
/**
* 授权的api
*/
public
abstract
String
authorize
();
/**
* 获取accessToken的api
*/
public
abstract
String
accessToken
();
/**
* 获取用户信息的api
*/
public
abstract
String
userInfo
();
/**
* 取消授权的api
*/
public
abstract
String
revoke
();
/**
* 刷新授权的api
*/
public
abstract
String
refresh
();
}
src/main/java/me/zhyd/oauth/model/AuthUserGender.java
浏览文件 @
79574a66
package
me.zhyd.oauth.model
;
import
java.util.Arrays
;
/**
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
...
...
@@ -19,10 +21,12 @@ public enum AuthUserGender {
if
(
code
==
null
)
{
return
UNKNOW
;
}
if
(
"m"
.
equals
(
code
)
||
"男"
.
equals
(
code
)
||
"1"
.
equals
(
code
)
||
"male"
.
equalsIgnoreCase
(
code
)
||
"F"
.
equalsIgnoreCase
(
code
))
{
String
[]
males
=
{
"m"
,
"男"
,
"1"
,
"male"
,
"F"
};
if
(
Arrays
.
asList
(
males
).
contains
(
code
))
{
return
MALE
;
}
if
(
"f"
.
equals
(
code
)
||
"女"
.
equals
(
code
)
||
"0"
.
equals
(
code
)
||
"female"
.
equalsIgnoreCase
(
code
))
{
String
[]
females
=
{
"f"
,
"女"
,
"0"
,
"female"
};
if
(
Arrays
.
asList
(
females
).
contains
(
code
))
{
return
FEMALE
;
}
return
UNKNOW
;
...
...
src/test/java/me/zhyd/oauth/AuthRequestTest.java
浏览文件 @
79574a66
...
...
@@ -116,6 +116,19 @@ public class AuthRequestTest {
authRequest
.
login
(
"code"
);
}
@Test
public
void
qqTest
()
{
AuthRequest
authRequest
=
new
AuthQqRequest
(
AuthConfig
.
builder
()
.
clientId
(
"clientId"
)
.
clientSecret
(
"clientSecret"
)
.
redirectUri
(
"redirectUri"
)
.
build
());
// 返回授权页面,可自行调整
String
url
=
authRequest
.
authorize
();
// 授权登录后会返回一个code,用这个code进行登录
AuthResponse
login
=
authRequest
.
login
(
"code"
);
}
@Test
public
void
wechatTest
()
{
AuthRequest
authRequest
=
new
AuthWeChatRequest
(
AuthConfig
.
builder
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录