【发布时间】:2017-01-14 14:33:01
【问题描述】:
我正在使用 Uber API 并尝试从 here 获取付款信息并收到以下错误,我不知道为什么。
httpget 响应:未经授权 {"message":"至少需要一个范围。可用范围:","code":"unauthorized"}
我正在使用Uber OAuth 2.0 authentication 并在步骤 1 中发送如下请求的范围。
static SessionConfiguration createSessionConfiguration() throws IOException {
// Load the client ID and secret from a secrets properties file.
Properties secrets = loadSecretProperties();
String clientId = secrets.getProperty("clientId");
String clientSecret = secrets.getProperty("clientSecret");
if (clientId.equals("INSERT_CLIENT_ID_HERE") || clientSecret.equals("INSERT_CLIENT_SECRET_HERE")) {
throw new IllegalArgumentException(
"Please enter your client ID and secret in the resoures/secrets.properties file.");
}
String scope = Scope.PAYMENT_METHODS.toString() + " "
+ Scope.PROFILE.toString() + " "
+ Scope.HISTORY.toString() + " "
+ Scope.PLACES.toString();
return new SessionConfiguration.Builder()
.setClientId(clientId)
.setClientSecret(clientSecret)
.setRedirectUri(REDIRECT_URI)
.setCustomScopes(Collections.singletonList(scope))
.build();
}
但是当我尝试从第 1 步打印范围信息时 .. 它看起来像这样 .. 但我没有看到付款方式范围回来了。
{
"last_authenticated" : "0",
"access_token" : "cc121212121212OoaIitK59azgf33",
"expires_in" : "2592011",
"token_type" : "Bearer",
"scope" : "profile ride_widgets places history_lite history",
"refresh_token" : "asasasI0ILhQ82q42tUOuyginNAFnD"
}
******* 那么我请求范围的方式是否错误?要么 ******* 我需要根据here 请求完全访问权限吗?
请告知..提前谢谢。
【问题讨论】:
标签: java google-app-engine uber-api