I am working on Uber API's and trying to get Payment Information from here and getting following error and I am not sure why.
httpget response:Unauthorized {"message":"Requires at least one scope. Available scopes: ","code":"unauthorized"}
I am using Uber OAuth 2.0 authentication and sending scopes requested as below at Step 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();
}
but when i try to print Scope information from STEP 1 .. it looks something like this .. but i am not seeing Payment method scope coming back.
{
"last_authenticated" : "0",
"access_token" : "cc121212121212OoaIitK59azgf33",
"expires_in" : "2592011",
"token_type" : "Bearer",
"scope" : "profile ride_widgets places history_lite history",
"refresh_token" : "asasasI0ILhQ82q42tUOuyginNAFnD"
}
******* So am I requesting scope wrong way? OR ******* do I need to request for full access as per here ?
Please advise .. thank you in advance.
There is no longer a payment_method scope. You just need the 'request' scope to access the payment method endpoints. You can remove the ride_widgets and payment_methods scopes from your example and add 'request' and it should work.
It looks like the sdk you are using is a bit outdated, so I would recommend updating if possible.
See more details in the payment method docs: https://developer.uber.com/docs/rides/api/v1-payment-methods
As this is a privileged scope you can use for your developer account, but will need to request full access in the developer dashboard for all users to access in production.