Uber /v1/payment-methods - 给出错误 "Unauthorized",可用范围为空
Uber /v1/payment-methods - giving error "Unauthorized" with Available scopes empty
我正在优步 API 工作并尝试从 here 获取付款信息并收到以下错误,我不确定为什么。
httpget response:Unauthorized
{"message":"Requires at least one scope. Available scopes: ","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 请求完全访问权限?
请指教..提前谢谢。
不再有 payment_method 作用域。您只需要 'request' 范围即可访问付款方式端点。您可以从示例中删除 ride_widgets 和 payment_methods 范围并添加 'request' 它应该可以工作。
看来您使用的sdk有点过时了,所以我建议尽可能更新。
在付款方式文档中查看更多详细信息:https://developer.uber.com/docs/rides/api/v1-payment-methods
由于这是一个特权范围,您可以将其用于您的开发者帐户,但需要在开发者仪表板中请求完全访问权限,以便所有用户在生产中访问。
我正在优步 API 工作并尝试从 here 获取付款信息并收到以下错误,我不确定为什么。
httpget response:Unauthorized {"message":"Requires at least one scope. Available scopes: ","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 请求完全访问权限?
请指教..提前谢谢。
不再有 payment_method 作用域。您只需要 'request' 范围即可访问付款方式端点。您可以从示例中删除 ride_widgets 和 payment_methods 范围并添加 'request' 它应该可以工作。
看来您使用的sdk有点过时了,所以我建议尽可能更新。
在付款方式文档中查看更多详细信息:https://developer.uber.com/docs/rides/api/v1-payment-methods
由于这是一个特权范围,您可以将其用于您的开发者帐户,但需要在开发者仪表板中请求完全访问权限,以便所有用户在生产中访问。