Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Rally java rest API获取连接ID/AuthToken_Java_Rest_Rally - Fatal编程技术网

如何从Rally java rest API获取连接ID/AuthToken

如何从Rally java rest API获取连接ID/AuthToken,java,rest,rally,Java,Rest,Rally,为了找到连接,我们在响应中是否有cookie,或者在最新的连接id、身份验证令牌中,类通过受保护的attachSecurityInfo()方法获取Rally SecurityToken。您可以从第377行开始查看上面链接中的源代码,了解attachSecurityInfo是如何请求令牌的,但这里概述了它的关键: protected static final String SECURITY_TOKEN_PARAM_KEY = "key"; private static final String S

为了找到连接,我们在响应中是否有cookie,或者在最新的连接id、身份验证令牌中,类通过受保护的attachSecurityInfo()方法获取Rally SecurityToken。您可以从第377行开始查看上面链接中的源代码,了解attachSecurityInfo是如何请求令牌的,但这里概述了它的关键:

protected static final String SECURITY_TOKEN_PARAM_KEY = "key";
private static final String SECURITY_TOKEN_URL = "/security/authorize";
protected static final String SECURITY_TOKEN_KEY = "SecurityToken";

GetResponse getResponse = getWithForceReauth(new GetRequest(SECURITY_TOKEN_URL));
JsonObject operationResult = getResponse.getObject();
JsonPrimitive securityTokenPrimitive = operationResult.getAsJsonPrimitive(SECURITY_TOKEN_KEY);
securityToken = securityTokenPrimitive.getAsString();

public GetResponse getWithForceReauth(GetRequest request) throws IOException {
    return get(request, true);
}
请注意,这仅适用于Java REST包版本1.07或更高版本,并且需要(并且是)Rally Webservices API 1.42或更高版本