代码拉取完成,页面将自动刷新
同步操作将从 CodeJason/飞书服务端SDK java 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package com.larksuite.oapi.sample.api;
import com.larksuite.oapi.core.AppSettings;
import com.larksuite.oapi.core.Config;
import com.larksuite.oapi.core.api.BatchReqCall;
import com.larksuite.oapi.core.api.ReqCallResult;
import com.larksuite.oapi.core.api.request.Request;
import com.larksuite.oapi.core.api.response.Response;
import com.larksuite.oapi.core.utils.Jsons;
import com.larksuite.oapi.sample.config.Configs;
import com.larksuite.oapi.service.authen.v1.AuthenService;
import com.larksuite.oapi.service.authen.v1.model.AuthenAccessTokenReqBody;
import com.larksuite.oapi.service.authen.v1.model.AuthenRefreshAccessTokenReqBody;
import com.larksuite.oapi.service.authen.v1.model.UserAccessTokenInfo;
import com.larksuite.oapi.service.authen.v1.model.UserInfo;
import java.util.List;
import java.util.concurrent.ExecutionException;
public class AuthenSample {
// for Cutome APP(自建应用)
private static final AppSettings appSettings = Config.getInternalAppSettingsByEnv();
// config with redis store
private static final Config config = Configs.getConfigWithRedisStore("https://open.feishu.cn", appSettings);
// private static final Config config = Configs.getConfig("https://open.feishu.cn", appSettings);
// private static final Config config = Configs.getConfig(Domain.FeiShu, appSettings);
public static void main(String[] args) throws Exception {
testAccessToken();
//testFreshAccessToken();
//testUserInfo();
}
private static void testAccessToken() throws Exception {
AuthenService service = new AuthenService(config);
AuthenAccessTokenReqBody body = new AuthenAccessTokenReqBody();
body.setGrantType("authorization_code");
body.setCode("lYuFiIZKtOuKd4zrLO8soc");
AuthenService.AuthenAccessTokenReqCall reqCall = service.getAuthens().accessToken(body);
Response<UserAccessTokenInfo> response = reqCall.execute();
System.out.println(Jsons.DEFAULT_GSON.toJson(response));
System.out.println(Jsons.DEFAULT_GSON.toJson(response.getData()));
System.out.println(response.getRequestID());
}
private static void testFreshAccessToken() throws Exception {
AuthenService service = new AuthenService(config);
AuthenRefreshAccessTokenReqBody body = new AuthenRefreshAccessTokenReqBody();
body.setGrantType("refresh_token");
body.setRefreshToken("[refresh_token]");
AuthenService.AuthenRefreshAccessTokenReqCall reqCall = service.getAuthens().refreshAccessToken(body);
Response<UserAccessTokenInfo> response = reqCall.execute();
System.out.println(Jsons.DEFAULT_GSON.toJson(response));
System.out.println(response.getRequestID());
}
private static void testUserInfo() throws Exception {
AuthenService service = new AuthenService(config);
AuthenService.AuthenUserInfoReqCall reqCall = service.getAuthens().userInfo(Request.setUserAccessToken("u-7B5D40vAJryhYyf6eigcxf"));
Response<UserInfo> response = reqCall.execute();
System.out.println(Jsons.DEFAULT_GSON.toJson(response.getData()));
System.out.println(response.getRequestID());
}
private static void batchAccessToken() {
AuthenService service = new AuthenService(config);
AuthenAccessTokenReqBody body = new AuthenAccessTokenReqBody();
body.setCode("[code]");
body.setGrantType("authorization_code");
AuthenService.AuthenAccessTokenReqCall reqCall1 = service.getAuthens().accessToken(body);
AuthenService.AuthenAccessTokenReqCall reqCall2 = service.getAuthens().accessToken(body);
BatchReqCall<AuthenAccessTokenReqBody, UserAccessTokenInfo> batchReqCall = new BatchReqCall<>(reqCall1, reqCall2);
try {
List<ReqCallResult<AuthenAccessTokenReqBody, UserAccessTokenInfo>> reqCallResults = batchReqCall.call();
for (ReqCallResult<AuthenAccessTokenReqBody, UserAccessTokenInfo> reqCallResult : reqCallResults) {
if (reqCallResult.getException() != null) {
System.out.println(reqCallResult.getException().getMessage());
return;
}
System.out.println(reqCallResult.getResponse().getRequestID());
System.out.println(reqCallResult.getResponse().getHTTPStatusCode());
System.out.println(Jsons.DEFAULT_GSON.toJson(reqCallResult.getResponse()));
}
} catch (ExecutionException | InterruptedException apiException) {
apiException.printStackTrace();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。