Oauth 此端点至少需要以下作用域之一:profile、surge\u accept、request、request.delegate
我正在使用Uber API开发一个应用程序,我使用改装库从API检索数据 我已使用以下端点授权我的应用程序:Oauth 此端点至少需要以下作用域之一:profile、surge\u accept、request、request.delegate,oauth,uber-api,Oauth,Uber Api,我正在使用Uber API开发一个应用程序,我使用改装库从API检索数据 我已使用以下端点授权我的应用程序: https://login.uber.com/oauth/v2/authorize?client_id=<CLIENT_ID>&response_type=code https://api.uber.com/v1.2/requests/estimate?start_latitude=37.7752278&start_longitude=-122.419751
https://login.uber.com/oauth/v2/authorize?client_id=<CLIENT_ID>&response_type=code
https://api.uber.com/v1.2/requests/estimate?start_latitude=37.7752278&start_longitude=-122.4197513&end_latitude=37.7773228&end_longitude=-122.4272052
然后我遇到了一个问题:
此终结点至少需要以下作用域之一:配置文件、缓冲\u接受、request.delegate.tos\u接受、request、request.delegate、“代码”:“未授权”
在实现这个端点之前,我已经按照优步官方文档完成了授权和令牌过程
我还在下面展示我的源代码,请告诉我哪里出了问题:
----> Intializing UBER SDK <----
public void initializeUber() {
if (!UberSdk.isInitialized()) {
configuration = new SessionConfiguration.Builder().setClientId("LWOUTh3AUBkVtaI-cK58-t_pspsvRFfk").setServerToken("J5MNweewRs8vj4-dC0r9OMI4-qjibix0xv6gncGs").setRedirectUri("REDIRECT_URL").setScopes(Arrays.asList(Scope.REQUEST)).setEnvironment(SessionConfiguration.Environment.SANDBOX).build();
UberSdk.initialize(configuration);
accessTokenManager = new AccessTokenManager(context);
System.out.println("Configuration- ---->
"+configuration.toString());
loginManager = new LoginManager(accessTokenManager, new UberLoginCallback(context), configuration, LOGIN_CODE);
} else {
Log.i(TAG, "Uber SDK already initialized");
}
}
public LoginManager getLoginManager() {
PreferenceManager(context).setUberAuthToken(loginManager.getAccessTokenManager().getAccessToken().toString());
System.out.println("Is authenticated-+loginManager.getAccessTokenManager().getAccessToken());
return loginManager;
}
-----> Created API Interface <----
@POST("v1.2/requests/estimate?")
Call<RequestEstimateFare> getRequestEstimateFare(@Query("start_latitude") String start_latitude, @Query("start_longitude") String start_longitude, @Query("end_latitude") String end_latitude, @Query("end_longitude") String end_longitude);
----> Retrofit Library calling <-----
apiInterface = retrofitConfig.createService(ApiInterface.class);
retrofitConfig.changeApiBaseUrl("https://api.uber.com/");
apiInterface.getRequestEstimateFare ("37.7752315", "-122.418075", "37.7752415", "-122.518075").enqueue(new Callback<RequestEstimateFare>() {
@Override
public void onResponse(Call<RequestEstimateFare> call, Response<RequestEstimateFare> response) {
}
@Override
public void onFailure(Call<RequestEstimateFare> call, Throwable t) {
}
});
--->初始化UBER SDK首先,您是否作为5个已批准的开发者帐户之一提出此请求?或者您是否已请求完全访问
特权作用域此终结点需要使用特权作用域
所有优步车手都在生产中。您可以使用此端点
当认证为您本人或您的5位注册会员中的任何一位时,立即
开发者。当您准备广泛分发应用程序时
对于所有优步车手,您可以请求完全访问。更多
阅读有关作用域的信息
其次,我不确定您的请求是如何使用查询参数而不是JSON请求体工作的?我只能使用
{"start_latitude": 37.7752278, "start_longitude": -122.4197513, "end_latitude": 37.7773228, "end_longitude":-122.4272052}
问题是您在oauth授权过程中没有请求“request”作用域
比如:
https://login.uber.com/oauth/v2/authorize?client_id=&response_type=code&scope=request
或者,如果您需要所有范围,则需要传递all in链接,如:
https://login.uber.com/oauth/v2/authorize?client_id=&response_type=code&scope=request 请求\u接收历史档案
如果没有正确的代码块,很难阅读文章