此端点至少需要以下范围之一:profile、surge_accept、request、request.delegate [英] This endpoint requires at least one of the following scopes: profile, surge_accept, request, request.delegate

查看:77
本文介绍了此端点至少需要以下范围之一:profile、surge_accept、request、request.delegate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Uber API 开发应用程序,我使用 Retrofit 库从 API 检索数据.

I am developing an application using Uber API, I used Retrofit library for retrieving data from API.

我已使用以下端点授权我的应用程序:

I have authorized my application using below endpoint:

https://login.uber.com/oauth/v2/authorize?client_id=<CLIENT_ID>&response_type=code

但是当我尝试使用以下端点估算产品时:

But when I tried to get estimates of products using below endpoint:

https://api.uber.com/v1.2/requests/estimate?start_latitude=37.7752278&start_longitude=-122.4197513&end_latitude=37.7773228&end_longitude=-122.4272052

然后我遇到了一个问题:

Then I got an issue:

此端点至少需要以下范围之一:profile、surge_accept、request.delegate.tos_accept、request、request.delegate","code":"unauthorized

This endpoint requires at least one of the following scopes: profile, surge_accept, request.delegate.tos_accept, request, request.delegate","code":"unauthorized

在实现这个端点之前,我已经完成了授权&遵循 Uber 官方文档的令牌程序.

Before implementing this endpoint I have completely done authorization & token procedure by following Uber official doc.

另外我在下面展示了我的源代码,请让我知道我哪里出错了:

Also I'm showing my source code below please let me know where I'm going wrong:

----> 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) {
    }
});

我仍然遇到同样的问题.

I'm still getting the same issue.

推荐答案

问题是您在 oauth 授权过程中没有请求 'request' 范围.

The problem is you have not requested the 'request' scope during the oauth authorization process.

喜欢:https://login.uber.com/oauth/v2/authorize?client_id=&response_type=code&scope=request

或者如果您想要所有范围,那么您需要在链接中传递所有内容,例如:https://login.uber.com/oauth/v2/authorize?client_id=<CLIENT_ID>&response_type=code&scope=request request_receipt history profile

or if you want all scope then you need to pass all in link like: https://login.uber.com/oauth/v2/authorize?client_id=<CLIENT_ID>&response_type=code&scope=request request_receipt history profile

这篇关于此端点至少需要以下范围之一:profile、surge_accept、request、request.delegate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆