我试图使用V1 Java SDK和V1访问令牌对我的VersionOne实例进行身份验证。我遵循creating acess tokens和creating a connection的文档准备好使其发挥作用。使用VersionOne访问令牌的Java SDK身份验证
问题是我一直运行到一个ConnectionException,声明“401无法验证”消息(下面的堆栈跟踪)。什么可能导致这个?
开发环境
- VersionOne的冬季'15使用Windows集成身份验证(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)
您能够与.withWindowsIntegrated()方法来验证? –
使用.withWindowsIntegrated()方法创建连接器可以正常工作。问题是我们想要使用除当前登录到计算机的帐户以外的帐户连接到VersionOne实例。 – Raynard
此外,我还尝试使用当前Windows用户的访问令牌,但没有得到它的工作。 – Raynard