我正在尝试使用 V1 Java SDK 和 V1 访问令牌对我的 VersionOne 实例进行身份验证。我按照文档创建访问令牌并创建连接以准备使其工作。
问题是我一直遇到 ConnectionException 说明“401 无法验证”消息(下面的堆栈跟踪)。这可能是什么原因造成的?
开发环境
- 使用 Windows 集成身份验证的 VersionOne Winter '15 (15.0.13.7283)
- VersionOne.SDK.Java.APIClient 15.0.0
源代码
// build the connector using an access token
V1Connector connector = V1Connector.withInstanceUrl("https://servername/instancetoauthenticate")
.withUserAgentHeader("Application", "1.0")
.withAccessToken("1.WkEciqwKNW7Pnvw9CNmPgQWIdL4=")
.build();
// use the connector to instantiate a Services object
IServices services = new Services(connector);
// check the logged in member
Oid oid = services.loggedIn;
System.out.println("Member Oid: " + oid);
堆栈跟踪
Exception in thread "main" com.versionone.apiclient.exceptions.ConnectionException:
HTTP/1.1 401 Unauthorized error code: 401 Could not authenticate. The VersionOne credentials may be incorrect or the access tokens may have expired.
at com.versionone.apiclient.V1Connector.manageErrors(V1Connector.java:423)
at com.versionone.apiclient.V1Connector.getData(V1Connector.java:368)
at com.versionone.apiclient.Services.retrieve(Services.java:114)
at com.versionone.apiclient.Services.getLoggedIn(Services.java:254)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at org.codehaus.groovy.runtime.metaclass.MethodMetaProperty$GetBeanMethodMetaProperty.getProperty(MethodMetaProperty.java:73)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:61)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
at com.netsuite.versionone.exporttasks.Authenticator.main(Authenticator.groovy:30)