HTTPGet 使用 Auth Token 抛出错误代码 403
HTTPGet using Auth Token throwing error code 403
我正在尝试从带有授权令牌的 URI 获取响应。
public void executeReponse(){
URI uri = new URIBuilder()
.setScheme("http")
.setHost(<host>)
.setPath(<path>)
.setParameter("token", Auth.getAuthToken(URL, UNAME, PWD))
.build();
//Auth.getAuthToken() returns my authToken
HttpGet httpGet = new HttpGet(uri);
CloseableHttpResponse response = httpclient.execute(httpGet);
int responseCode = response.getStatusLine().getStatusCode();
System.out.println("Request Url: " + httpGet.getURI());
System.out.println("Response Code: " + responseCode);
}
执行此操作后,出现以下错误
Response Code: 403
我已经用 URI 提供了令牌,但它仍然没有授权。
谁能帮我解决这个问题
错误代码403 Forbidden
表示:服务器知道你是谁,但认为你无权访问你试图请求的资源(例如:如果用户A试图访问用户B的私人 Facebook 消息)。
这与401 Unauthorized
形成对比,这意味着:服务器不知道您是谁,您请求的资源需要您获得授权。
确保您拥有尝试连接的服务的正确凭据。如果您也在开发该服务,请检查您对该资源的访问权限。
我正在尝试从带有授权令牌的 URI 获取响应。
public void executeReponse(){
URI uri = new URIBuilder()
.setScheme("http")
.setHost(<host>)
.setPath(<path>)
.setParameter("token", Auth.getAuthToken(URL, UNAME, PWD))
.build();
//Auth.getAuthToken() returns my authToken
HttpGet httpGet = new HttpGet(uri);
CloseableHttpResponse response = httpclient.execute(httpGet);
int responseCode = response.getStatusLine().getStatusCode();
System.out.println("Request Url: " + httpGet.getURI());
System.out.println("Response Code: " + responseCode);
}
执行此操作后,出现以下错误
Response Code: 403
我已经用 URI 提供了令牌,但它仍然没有授权。
谁能帮我解决这个问题
错误代码403 Forbidden
表示:服务器知道你是谁,但认为你无权访问你试图请求的资源(例如:如果用户A试图访问用户B的私人 Facebook 消息)。
这与401 Unauthorized
形成对比,这意味着:服务器不知道您是谁,您请求的资源需要您获得授权。
确保您拥有尝试连接的服务的正确凭据。如果您也在开发该服务,请检查您对该资源的访问权限。