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

我是研究僧i 提交于 2021-02-08 10:12:35

问题


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:

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

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.


回答1:


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

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

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




回答2:


Firstly, are you making this request as one of your 5 approved developer accounts? or have you requested FULL ACCESS?

https://developer.uber.com/docs/riders/references/api/v1.2/requests-estimate-post

Privileged Scope This endpoint requires a privileged scope to be used in production by all Uber riders. You can use this endpoint immediately when authenticated as yourself or any of your 5 registered developers. When you are ready to distribute your application broadly for use by all Uber riders, you may request FULL ACCESS. For more information read about scopes.

Secondary to that I'm not sure how your request is working using query params instead of a JSON request body? I can only get your query working using

{"start_latitude": 37.7752278, "start_longitude": -122.4197513, "end_latitude": 37.7773228, "end_longitude":-122.4272052}


来源:https://stackoverflow.com/questions/45912281/this-endpoint-requires-at-least-one-of-the-following-scopes-profile-surge-acce

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!