Skip to content

Commit 4968b85

Browse files
authored
Merge pull request #61 from Authing/feat/code-2-token
feat: 根据 code 获取token 支持指定 redirectUri
2 parents 25dd5fd + 06f9d66 commit 4968b85

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>cn.authing</groupId>
88
<artifactId>authing-java-sdk</artifactId>
9-
<version>3.1.5</version>
9+
<version>3.1.6</version>
1010

1111
<name>Authing Java SDK</name>
1212
<description>java backend sdk for authing</description>

src/main/java/cn/authing/sdk/java/client/AuthenticationClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public AccessToken introspectAccessTokenOffline(String token) throws Exception {
100100
}
101101

102102
public OIDCTokenResponse getAccessTokenByCode(String code) throws Exception {
103+
return this.getAccessTokenByCode(code, this.options.getRedirectUri());
104+
}
105+
106+
public OIDCTokenResponse getAccessTokenByCode(String code, String redirectUri) throws Exception {
103107
if ((StrUtil.isBlank(this.options.getAppId()) || StrUtil.isBlank(this.options.getAppSecret()))
104108
&& this.options.getTokenEndPointAuthMethod() != AuthMethodEnum.NONE.getValue()) {
105109
throw new Exception("请在初始化 AuthenticationClient 时传入 appId 和 secret 参数");
@@ -113,7 +117,7 @@ public OIDCTokenResponse getAccessTokenByCode(String code) throws Exception {
113117
}
114118

115119
CodeToTokenParams tokenParam = new CodeToTokenParams();
116-
tokenParam.setRedirectUri(this.options.getRedirectUri());
120+
tokenParam.setRedirectUri(redirectUri);
117121
tokenParam.setCode(code);
118122
tokenParam.setGrantType("authorization_code");
119123

0 commit comments

Comments
 (0)