1
This commit is contained in:
@@ -60,12 +60,22 @@ public class WPS365OAuthServiceImpl implements IWPS365OAuthService {
|
||||
StringBuilder authUrl = new StringBuilder();
|
||||
authUrl.append(oauthUrl);
|
||||
authUrl.append("?client_id=").append(appId);
|
||||
|
||||
// 重要:redirect_uri必须与WPS365开放平台配置的回调地址完全一致
|
||||
// 包括协议(https)、域名、路径,不能有多余的斜杠
|
||||
String finalRedirectUri = redirectUri.trim();
|
||||
// 确保URL末尾没有斜杠(除非是根路径)
|
||||
if (finalRedirectUri.endsWith("/") && !finalRedirectUri.equals("https://")) {
|
||||
finalRedirectUri = finalRedirectUri.substring(0, finalRedirectUri.length() - 1);
|
||||
}
|
||||
|
||||
try {
|
||||
String encodedRedirectUri = java.net.URLEncoder.encode(redirectUri, "UTF-8");
|
||||
String encodedRedirectUri = java.net.URLEncoder.encode(finalRedirectUri, "UTF-8");
|
||||
authUrl.append("&redirect_uri=").append(encodedRedirectUri);
|
||||
log.info("使用回调地址: {} (编码后: {})", finalRedirectUri, encodedRedirectUri);
|
||||
} catch (java.io.UnsupportedEncodingException e) {
|
||||
log.error("URL编码失败", e);
|
||||
authUrl.append("&redirect_uri=").append(redirectUri);
|
||||
authUrl.append("&redirect_uri=").append(finalRedirectUri);
|
||||
}
|
||||
authUrl.append("&response_type=code");
|
||||
// WPS365的scope,根据官方文档设置
|
||||
@@ -80,6 +90,8 @@ public class WPS365OAuthServiceImpl implements IWPS365OAuthService {
|
||||
|
||||
String result = authUrl.toString();
|
||||
log.info("生成授权URL: {}", result);
|
||||
log.warn("⚠️ 请确保WPS365开放平台配置的回调地址与以下地址完全一致(包括协议、域名、路径):");
|
||||
log.warn("⚠️ 回调地址: {}", finalRedirectUri);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user