我正在使用Uber API并尝试从here获取付款信息并收到以下错误,我不确定原因。
httpget响应:未经授权 {" message":"至少需要一个范围。可用范围:","代码":"未授权"}
我正在使用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();
}
但是当我尝试从STEP 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请求完全访问权限?
请指教..提前谢谢你。
答案 0 :(得分:1)
不再有payment_method范围。您只需要“请求”范围即可访问付款方式端点。您可以从示例中删除ride_widgets和payment_methods范围,然后添加“请求”,它应该有效。
看起来你使用的sdk有点过时了,所以如果可能的话我会建议更新。
在付款方式文档中查看详细信息:https://developer.uber.com/docs/rides/api/v1-payment-methods
由于这是您可以用于开发者帐户的特权范围,但需要在开发人员信息中心中请求完全访问权限,以便所有用户都可以在生产中访问。