-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Expand file tree
/
Copy pathWxOAuth2Service.java
More file actions
72 lines (65 loc) · 1.98 KB
/
Copy pathWxOAuth2Service.java
File metadata and controls
72 lines (65 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
/**
* oauth2 相关接口.
*
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* @date 2020-08-08
*/
public interface WxOAuth2Service {
/**
* <pre>
* 构造oauth2授权的url连接.
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
* </pre>
*
* @param redirectURI 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode
* @param scope scope
* @param state state
* @return url
*/
String buildAuthorizationUrl(String redirectURI, String scope, String state);
/**
* <pre>
* 用code换取oauth2的access token.
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
* </pre>
*
* @param code code
* @return token对象
* @throws WxErrorException .
*/
WxMpOAuth2AccessToken getAccessToken(String code) throws WxErrorException;
/**
* <pre>
* 刷新oauth2的access token.
* </pre>
*
* @param refreshToken 刷新token
* @return 新的token对象
* @throws WxErrorException .
*/
WxMpOAuth2AccessToken refreshAccessToken(String refreshToken) throws WxErrorException;
/**
* <pre>
* 用oauth2获取用户信息, 当前面引导授权时的scope是snsapi_userinfo的时候才可以.
* </pre>
*
* @param oAuth2AccessToken token对象
* @param lang zh_CN, zh_TW, en
* @return 用户对象
* @throws WxErrorException .
*/
WxMpUser getUserInfo(WxMpOAuth2AccessToken oAuth2AccessToken, String lang) throws WxErrorException;
/**
* <pre>
* 验证oauth2的access token是否有效.
* </pre>
*
* @param oAuth2AccessToken token对象
* @return 是否有效
*/
boolean validateAccessToken(WxMpOAuth2AccessToken oAuth2AccessToken);
}