Docusign Java API无法获取帐户Id



我的代码看起来像:

ApiClient client = new ApiClient(DEMO_REST_BASEPATH);
String clientId = "65f9b5d9-XXXX-4de6-ab3c-XXXX";
java.util.List<String> scopes = new ArrayList<String>();
scopes.add(OAuth.Scope_SIGNATURE);
byte[]  key = Files.readAllBytes(Paths.get("/tmp/privateKey"));
OAuth.OAuthToken token = client.requestJWTApplicationToken(clientId, scopes, key, 3600);
System.err.println(token.getAccessToken());
OAuth.UserInfo userInfo = client.getUserInfo(token.getAccessToken());
System.out.println("UserInfo: " + userInfo);

我看到我得到了一个身份验证令牌,但我在尝试获取UserInfo:时收到了一条错误消息

Exception in thread "main" com.docusign.esign.client.ApiException: Error while requesting server, received a non successful HTTP code 401 with response Body: '{"error":"internal_server_error","reference_id":"22e7cf18-74b4-48aa-b916-81bde96071ae"}'
at com.docusign.esign.client.ApiClient.getUserInfo(ApiClient.java:760)

有什么想法吗?

您缺少这一行:(GitHub上的示例(

client.setAccessToken(oAuthToken.getAccessToken(), oAuthToken.getExpiresIn());

你的代码应该是这样的:

ApiClient client = new ApiClient(DEMO_REST_BASEPATH);
String clientId = "65f9b5d9-XXXX-4de6-ab3c-XXXX";
java.util.List<String> scopes = new ArrayList<String>();
scopes.add(OAuth.Scope_SIGNATURE);
byte[]  key = Files.readAllBytes(Paths.get("/tmp/privateKey"));
OAuth.OAuthToken token = client.requestJWTApplicationToken(clientId, scopes, key, 3600);
System.err.println(token.getAccessToken());
client.setAccessToken(oAuthToken.getAccessToken(), oAuthToken.getExpiresIn());
OAuth.UserInfo userInfo = client.getUserInfo(token.getAccessToken());
System.out.println("UserInfo: " + userInfo);

最新更新