forked from Wechat-Group/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 抽取oauth2相关接口方法到独立类WxOAuth2Service中
- Loading branch information
1 parent
4bd5b3c
commit 9346c17
Showing
5 changed files
with
311 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxOAuth2Service.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
|
||
} |
Oops, something went wrong.