mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
✨ 优化 OneDrive/SharePoint 获取 token 体验,增加信息显示,并优化页面效果。
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package im.zhaojun.zfile.admin.model.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -10,11 +9,41 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class OneDriveToken {
|
||||
|
||||
private String clientId;
|
||||
|
||||
private String clientSecret;
|
||||
|
||||
private String redirectUri;
|
||||
|
||||
@JSONField(name = "access_token")
|
||||
private String accessToken;
|
||||
|
||||
@JSONField(name = "refresh_token")
|
||||
private String refreshToken;
|
||||
|
||||
private boolean success;
|
||||
|
||||
private String body;
|
||||
|
||||
public static OneDriveToken success(String clientId, String clientSecret, String redirectUri, String accessToken, String refreshToken, String body) {
|
||||
OneDriveToken token = new OneDriveToken();
|
||||
token.setClientId(clientId);
|
||||
token.setClientSecret(clientSecret);
|
||||
token.setRedirectUri(redirectUri);
|
||||
token.setSuccess(true);
|
||||
token.setBody(body);
|
||||
token.setAccessToken(accessToken);
|
||||
token.setRefreshToken(refreshToken);
|
||||
return token;
|
||||
}
|
||||
|
||||
public static OneDriveToken fail(String clientId, String clientSecret, String redirectUri, String body) {
|
||||
OneDriveToken token = new OneDriveToken();
|
||||
token.setClientId(clientId);
|
||||
token.setClientSecret(clientSecret);
|
||||
token.setRedirectUri(redirectUri);
|
||||
token.setSuccess(false);
|
||||
token.setBody(body);
|
||||
return token;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import im.zhaojun.zfile.home.service.impl.OneDriveChinaServiceImpl;
|
||||
import im.zhaojun.zfile.home.service.impl.OneDriveServiceImpl;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -22,6 +23,7 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
@Api(tags = "OneDrive 认证回调模块")
|
||||
@Controller
|
||||
@Slf4j
|
||||
@RequestMapping(value = {"/onedrive", "/onedirve"})
|
||||
public class OneDriveCallbackController {
|
||||
|
||||
@@ -36,19 +38,24 @@ public class OneDriveCallbackController {
|
||||
@ApiOperationSupport(order = 1)
|
||||
@ApiOperation(value = "生成 OAuth2 登陆 URL", notes = "生成 OneDrive OAuth2 登陆 URL,用户国际版,家庭版等非世纪互联运营的 OneDrive.")
|
||||
public String authorize(String clientId, String clientSecret, String redirectUri) {
|
||||
log.info("onedrive 国际版生成授权链接参数信息: clientId: {}, clientSecret: {}, redirectUri: {}", clientId, clientSecret, redirectUri);
|
||||
|
||||
if (StrUtil.isAllEmpty(clientId, clientSecret, redirectUri)) {
|
||||
clientId = oneDriveServiceImpl.getClientId();
|
||||
redirectUri = oneDriveServiceImpl.getRedirectUri();
|
||||
clientSecret = oneDriveServiceImpl.getClientSecret();
|
||||
}
|
||||
|
||||
|
||||
String stateStr = "&state=" + Base64.encodeUrlSafe(StrUtil.join("::", clientId, clientSecret, redirectUri));
|
||||
|
||||
|
||||
String authorizeUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=" + clientId
|
||||
+ "&response_type=code&redirect_uri=" + redirectUri
|
||||
+ "&scope=" + oneDriveServiceImpl.getScope()
|
||||
+ stateStr;
|
||||
|
||||
log.info("onedrive 国际版生成授权链接结果: {}", authorizeUrl);
|
||||
|
||||
return "redirect:" + authorizeUrl;
|
||||
}
|
||||
|
||||
@@ -57,11 +64,15 @@ public class OneDriveCallbackController {
|
||||
@ApiOperationSupport(order = 2)
|
||||
@ApiOperation(value = "OAuth2 回调地址", notes = "根据 OAuth2 协议,登录成功后,会返回给网站一个 code,用此 code 去换取 accessToken 和 refreshToken.(oneDrive 会回调此接口)")
|
||||
public String oneDriveCallback(String code, String state, Model model) {
|
||||
log.info("onedrive 国际版授权回调参数信息: code: {}, state: {}", code, state);
|
||||
|
||||
String stateDecode = Base64.decodeStr(state);
|
||||
String[] stateArr = stateDecode.split("::");
|
||||
|
||||
OneDriveToken oneDriveToken = oneDriveServiceImpl.getToken(code, stateArr[0], stateArr[1], stateArr[2]);
|
||||
model.addAttribute("accessToken", oneDriveToken.getAccessToken());
|
||||
model.addAttribute("refreshToken", oneDriveToken.getRefreshToken());
|
||||
log.info("onedrive 国际版授权回调获取令牌结果: {}", oneDriveToken);
|
||||
|
||||
model.addAttribute("oneDriveToken", oneDriveToken);
|
||||
return "callback";
|
||||
}
|
||||
|
||||
@@ -70,6 +81,8 @@ public class OneDriveCallbackController {
|
||||
@ApiOperationSupport(order = 3)
|
||||
@ApiOperation(value = "生成 OAuth2 登陆 URL(世纪互联)", notes = "生成 OneDrive OAuth2 登陆 URL,用于世纪互联版本.")
|
||||
public String authorizeChina(String clientId, String clientSecret, String redirectUri) {
|
||||
log.info("onedrive 世纪互联版生成授权链接参数信息: clientId: {}, clientSecret: {}, redirectUri: {}", clientId, clientSecret, redirectUri);
|
||||
|
||||
if (StrUtil.isAllEmpty(clientId, clientSecret, redirectUri)) {
|
||||
clientId = oneDriveChinaServiceImpl.getClientId();
|
||||
redirectUri = oneDriveChinaServiceImpl.getRedirectUri();
|
||||
@@ -83,6 +96,9 @@ public class OneDriveCallbackController {
|
||||
+ "&response_type=code&redirect_uri=" + redirectUri
|
||||
+ "&scope=" + oneDriveChinaServiceImpl.getScope()
|
||||
+ stateStr;
|
||||
|
||||
log.info("onedrive 世纪互联版生成授权链接结果: {}", authorizeUrl);
|
||||
|
||||
return "redirect:" + authorizeUrl;
|
||||
}
|
||||
|
||||
@@ -91,11 +107,15 @@ public class OneDriveCallbackController {
|
||||
@ApiOperationSupport(order = 4)
|
||||
@ApiOperation(value = "OAuth2 回调地址(世纪互联)", notes = "根据 OAuth2 协议,登录成功后,会返回给网站一个 code,用此 code 去换取 accessToken 和 refreshToken.(oneDrive 会回调此接口)")
|
||||
public String oneDriveChinaCallback(String code, String state, Model model) {
|
||||
log.info("onedrive 世纪互联版授权回调参数信息: code: {}, state: {}", code, state);
|
||||
|
||||
String stateDecode = Base64.decodeStr(state);
|
||||
String[] stateArr = stateDecode.split("::");
|
||||
|
||||
OneDriveToken oneDriveToken = oneDriveChinaServiceImpl.getToken(code, stateArr[0], stateArr[1], stateArr[2]);
|
||||
model.addAttribute("accessToken", oneDriveToken.getAccessToken());
|
||||
model.addAttribute("refreshToken", oneDriveToken.getRefreshToken());
|
||||
log.info("onedrive 世纪互联版授权回调获取令牌结果: {}", oneDriveToken);
|
||||
|
||||
model.addAttribute("oneDriveToken", oneDriveToken);
|
||||
return "callback";
|
||||
}
|
||||
|
||||
|
||||
@@ -99,16 +99,26 @@ public abstract class MicrosoftDriveServiceBase<P extends MicrosoftDriveParam> e
|
||||
"&client_secret=" + getClientSecret() +
|
||||
"&refresh_token=" + refreshStorageSourceConfig.getValue() +
|
||||
"&grant_type=refresh_token";
|
||||
|
||||
|
||||
log.info("{} 尝试刷新令牌, 参数信息为: {}", this, param);
|
||||
|
||||
String fullAuthenticateUrl = AUTHENTICATE_URL.replace("{authenticateEndPoint}", getAuthenticateEndPoint());
|
||||
HttpRequest post = HttpUtil.createPost(fullAuthenticateUrl);
|
||||
|
||||
post.body(param, "application/x-www-form-urlencoded");
|
||||
HttpResponse response = post.execute();
|
||||
String body = response.body();
|
||||
log.info("{} 尝试刷新令牌成功, 响应信息为: {}", this, body);
|
||||
|
||||
JSONObject jsonBody = JSONObject.parseObject(body);
|
||||
|
||||
if (response.getStatus() != HttpStatus.OK.value()) {
|
||||
throw new RuntimeException(response.body());
|
||||
return OneDriveToken.fail(getClientId(), getClientSecret(), getRedirectUri(), body);
|
||||
}
|
||||
return JSONObject.parseObject(response.body(), OneDriveToken.class);
|
||||
|
||||
String accessToken = jsonBody.getString("access_token");
|
||||
String refreshToken = jsonBody.getString("refresh_token");
|
||||
return OneDriveToken.success(getClientId(), getClientSecret(), getRedirectUri(), accessToken, refreshToken, body);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,6 +130,7 @@ public abstract class MicrosoftDriveServiceBase<P extends MicrosoftDriveParam> e
|
||||
* @return 获取的 Token 信息.
|
||||
*/
|
||||
public OneDriveToken getToken(String code, String clientId, String clientSecret, String redirectUri) {
|
||||
log.info("{} 根据授权回调 code 获取令牌:code: {}, clientId: {}, clientSecret: {}, redirectUri: {}", this, code, clientId, clientSecret, redirectUri);
|
||||
String param = "client_id=" + clientId +
|
||||
"&redirect_uri=" + redirectUri +
|
||||
"&client_secret=" + clientSecret +
|
||||
@@ -132,7 +143,17 @@ public abstract class MicrosoftDriveServiceBase<P extends MicrosoftDriveParam> e
|
||||
|
||||
post.body(param, "application/x-www-form-urlencoded");
|
||||
HttpResponse response = post.execute();
|
||||
return JSONObject.parseObject(response.body(), OneDriveToken.class);
|
||||
String body = response.body();
|
||||
log.info("{} 根据授权回调 code 获取令牌结果:body: {}", this, body);
|
||||
JSONObject jsonBody = JSONObject.parseObject(body);
|
||||
|
||||
if (response.getStatus() != HttpStatus.OK.value()) {
|
||||
return OneDriveToken.fail(clientId, clientSecret, redirectUri, body);
|
||||
}
|
||||
|
||||
String accessToken = jsonBody.getString("access_token");
|
||||
String refreshToken = jsonBody.getString("refresh_token");
|
||||
return OneDriveToken.success(clientId, clientSecret, redirectUri, accessToken, refreshToken, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -365,7 +386,7 @@ public abstract class MicrosoftDriveServiceBase<P extends MicrosoftDriveParam> e
|
||||
OneDriveToken refreshToken = getRefreshToken();
|
||||
|
||||
if (refreshToken.getAccessToken() == null || refreshToken.getRefreshToken() == null) {
|
||||
return;
|
||||
throw new StorageSourceRefreshTokenException("获取或刷新 AccessToken 失败, 获取到的令牌为空, 相关诊断信息为: " + refreshToken, storageId);
|
||||
}
|
||||
|
||||
StorageSourceConfig accessTokenConfig =
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package im.zhaojun.zfile.home.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import im.zhaojun.zfile.admin.model.param.OneDriveChinaParam;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.home.service.base.AbstractOneDriveServiceBase;
|
||||
@@ -44,22 +43,31 @@ public class OneDriveChinaServiceImpl extends AbstractOneDriveServiceBase<OneDri
|
||||
public String getAuthenticateEndPoint() {
|
||||
return "login.partner.microsoftonline.cn";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientId(), clientId);
|
||||
if (param == null || param.getClientId() == null) {
|
||||
return clientId;
|
||||
}
|
||||
return param.getClientId();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRedirectUri() {
|
||||
return ObjectUtil.defaultIfNull(param.getRedirectUri(), redirectUri);
|
||||
if (param == null || param.getRedirectUri() == null) {
|
||||
return redirectUri;
|
||||
}
|
||||
return param.getRedirectUri();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getClientSecret() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientSecret(), clientSecret);
|
||||
if (param == null || param.getClientSecret() == null) {
|
||||
return clientSecret;
|
||||
}
|
||||
return param.getClientSecret();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScope() {
|
||||
return scope;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package im.zhaojun.zfile.home.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.admin.model.param.OneDriveParam;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.home.service.base.AbstractOneDriveServiceBase;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -47,17 +46,26 @@ public class OneDriveServiceImpl extends AbstractOneDriveServiceBase<OneDrivePar
|
||||
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientId(), clientId);
|
||||
if (param == null || param.getClientId() == null) {
|
||||
return clientId;
|
||||
}
|
||||
return param.getClientId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedirectUri() {
|
||||
return ObjectUtil.defaultIfNull(param.getRedirectUri(), redirectUri);
|
||||
if (param == null || param.getRedirectUri() == null) {
|
||||
return redirectUri;
|
||||
}
|
||||
return param.getRedirectUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientSecret() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientSecret(), clientSecret);
|
||||
if (param == null || param.getClientSecret() == null) {
|
||||
return clientSecret;
|
||||
}
|
||||
return param.getClientSecret();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package im.zhaojun.zfile.home.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.admin.model.param.SharePointChinaParam;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.home.service.base.AbstractSharePointServiceBase;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -47,19 +46,28 @@ public class SharePointChinaServiceImpl extends AbstractSharePointServiceBase<Sh
|
||||
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientId(), clientId);
|
||||
if (param == null || param.getClientId() == null) {
|
||||
return clientId;
|
||||
}
|
||||
return param.getClientId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedirectUri() {
|
||||
return ObjectUtil.defaultIfNull(param.getRedirectUri(), redirectUri);
|
||||
if (param == null || param.getRedirectUri() == null) {
|
||||
return redirectUri;
|
||||
}
|
||||
return param.getRedirectUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientSecret() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientSecret(), clientSecret);
|
||||
if (param == null || param.getClientSecret() == null) {
|
||||
return clientSecret;
|
||||
}
|
||||
return param.getClientSecret();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScope() {
|
||||
return scope;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package im.zhaojun.zfile.home.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.admin.model.param.SharePointParam;
|
||||
import im.zhaojun.zfile.home.model.enums.StorageTypeEnum;
|
||||
import im.zhaojun.zfile.home.service.base.AbstractSharePointServiceBase;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -47,19 +46,28 @@ public class SharePointServiceImpl extends AbstractSharePointServiceBase<SharePo
|
||||
|
||||
@Override
|
||||
public String getClientId() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientId(), clientId);
|
||||
if (param == null || param.getClientId() == null) {
|
||||
return clientId;
|
||||
}
|
||||
return param.getClientId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRedirectUri() {
|
||||
return ObjectUtil.defaultIfNull(param.getRedirectUri(), redirectUri);
|
||||
if (param == null || param.getRedirectUri() == null) {
|
||||
return redirectUri;
|
||||
}
|
||||
return param.getRedirectUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientSecret() {
|
||||
return ObjectUtil.defaultIfNull(param.getClientSecret(), clientSecret);
|
||||
if (param == null || param.getClientSecret() == null) {
|
||||
return clientSecret;
|
||||
}
|
||||
return param.getClientSecret();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScope() {
|
||||
return scope;
|
||||
|
||||
@@ -2,25 +2,99 @@
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>CallBack Result</title>
|
||||
<script src="https://cdn.jun6.net/uPic/2022/08/15/tailwind.js">
|
||||
</script>
|
||||
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/1.8.0/jquery-1.8.0.min.js"></script>
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/clipboard.js/2.0.10/clipboard.min.js"></script>
|
||||
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.5.1/layer.min.js"></script>
|
||||
<title>ZFile OneDrive / SharePoint 令牌获取结果</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>accessToken (访问令牌)</h1>
|
||||
<div>
|
||||
<input type="text" th:value="${accessToken}">
|
||||
<body class="w-full h-full">
|
||||
<div class="h-full min-h-screen bg-gray-100 text-gray-900 flex justify-center py-10">
|
||||
<div class="flex flex-1 max-w-screen-lg px-8 lg:0">
|
||||
<div class="w-full">
|
||||
<div class="relative overflow-auto">
|
||||
<div class="rounded mx-auto bg-white shadow py-5 px-6">
|
||||
<div class="text-2xl text-center mb-4">ZFile OneDrive / SharePoint 令牌获取结果</div>
|
||||
<form class="space-y-6">
|
||||
<div th:if="${oneDriveToken.success}" class="text-right">
|
||||
<span>状态:</span>
|
||||
<span class="text-green-500">获取成功</span>
|
||||
</div>
|
||||
<div th:if="${oneDriveToken.success == false}" class="text-right">
|
||||
<span>状态:</span>
|
||||
<span class="text-red-500">获取失败</span>
|
||||
</div>
|
||||
<div>
|
||||
<label for="accessToken" class="block text-sm font-medium text-slate-700">AccessToken (访问令牌)</label>
|
||||
<div class="mt-1">
|
||||
<input th:value="${oneDriveToken.accessToken}" type="text" name="accessToken" id="accessToken" class="px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1 invalid:border-pink-500 invalid:text-pink-600 focus:invalid:border-pink-500 focus:invalid:ring-pink-500">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="refreshToken" class="block text-sm font-medium text-slate-700">RefreshToken (刷新令牌)</label>
|
||||
<div class="mt-1">
|
||||
<input th:value="${oneDriveToken.refreshToken}" type="text" name="refreshToken" id="refreshToken" class="px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1 invalid:border-pink-500 invalid:text-pink-600 focus:invalid:border-pink-500 focus:invalid:ring-pink-500">
|
||||
</div>
|
||||
</div>
|
||||
<div class="border-t-4 border-dashed">
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
tips: 以下为诊断信息,如获取成功请忽略,获取失败无法自行解决时请截图下方所有内容发送给开发者,github: <a target="_blank" class="text-blue-500" href="https://github.com/zfile-dev/zfile/issues">https://github.com/zfile-dev/zfile/issues</a>。
|
||||
</div>
|
||||
<div>
|
||||
<label for="clientId" class="block text-sm font-medium text-slate-700">clientId (api id)</label>
|
||||
<div class="mt-1">
|
||||
<input th:value="${oneDriveToken.clientId}" type="text" name="clientId" id="clientId" class="px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1 invalid:border-pink-500 invalid:text-pink-600 focus:invalid:border-pink-500 focus:invalid:ring-pink-500">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="clientSecret" class="block text-sm font-medium text-slate-700">clientSecret (api 密钥)</label>
|
||||
<div class="mt-1">
|
||||
<input th:value="${oneDriveToken.clientSecret}" type="text" name="clientSecret" id="clientSecret" class="px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1 invalid:border-pink-500 invalid:text-pink-600 focus:invalid:border-pink-500 focus:invalid:ring-pink-500">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="redirectUri" class="block text-sm font-medium text-slate-700">redirectUri (回调地址)</label>
|
||||
<div class="mt-1">
|
||||
<input th:value="${oneDriveToken.redirectUri}" type="text" name="redirectUri" id="redirectUri" class="px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1 invalid:border-pink-500 invalid:text-pink-600 focus:invalid:border-pink-500 focus:invalid:ring-pink-500">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="body" class="block text-sm font-medium text-slate-700">响应体 (api 返回的完整信息)</label>
|
||||
<div class="mt-1">
|
||||
<textarea th:text="${oneDriveToken.body}" rows="10" name="body" id="body" class="px-3 py-2 bg-white border shadow-sm border-slate-300 placeholder-slate-400 focus:outline-none focus:border-sky-500 focus:ring-sky-500 block w-full rounded-md sm:text-sm focus:ring-1 invalid:border-pink-500 invalid:text-pink-600 focus:invalid:border-pink-500 focus:invalid:ring-pink-500"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h1>refreshToken (刷新令牌)</h1>
|
||||
<div>
|
||||
<input type="text" th:value="${refreshToken}">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<style>
|
||||
input {
|
||||
height: 30px;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="application/javascript">
|
||||
let clipboard = new ClipboardJS('input, textarea', {
|
||||
target: function(trigger) {
|
||||
console.log(trigger.value)
|
||||
return trigger;
|
||||
}
|
||||
});
|
||||
|
||||
clipboard.on('success', function(e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
layer.msg('复制成功', {icon: 1})
|
||||
e.trigger.select();
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
clipboard.on('error', function(e) {
|
||||
console.error('Action:', e.action);
|
||||
console.error('Trigger:', e.trigger);
|
||||
layer.msg('复制失败,请手动复制', {icon: 2})
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user