简体   繁体   中英

Uber Api.Authentication OAuth2 INVALID REQUEST PARAMETERS in GET /authorize

Hi,

The problem is following:

I was trying to call Get/authorize for Uber Api using C# Uber.SDK.

https://github.com/timothyclifford/uber-csharp-sdk

 public ActionResult Index()
    {
        var scopes = new List<string> { "profile", "history_lite", "request" };

        var uberClient = UberClientHelper.GetAuth();
        var response = uberClient.GetAuthorizeUrl(scopes, Guid.NewGuid().ToString());

        return View("Index", (object)response);
    }



 public string GetAuthorizeUrl(List<string> scopes = null, string state = null, string redirectUri = null)
    {
        //var authorizeUrl = string.Concat("https://login.uber.com/oauth/authorize?response_type=code&client_id=", _clientId);

        var authorizeUrl = string.Concat("https://login.uber.com/oauth/v2/authorize?client_id=", _clientId);

        authorizeUrl += string.Concat("&response_type=code");
        if (scopes != null && scopes.Any())
        {
            authorizeUrl += string.Concat("&scope=", string.Join(" ", scopes));
        }

        if (!string.IsNullOrWhiteSpace(state))
        {
            authorizeUrl += string.Concat("&state=", state);
        }

        if (!string.IsNullOrWhiteSpace(redirectUri))
        {
            authorizeUrl += string.Concat("&redirect_uri=", HttpUtility.UrlEncode(redirectUri));
        }
        // Result will be https://login.uber.com/oauth/v2/authorize?client_id={client_ID}=code&scope=profile
        return authorizeUrl;
    }

And as the result, some error Invalid Request Parameters pops up during the redirection by url.

I checked a lot of times if the url is correct together with parameters, but still have this error.

Error Page Example

Documentation https://developer.uber.com/docs/riders/references/api/v2/authorize-get

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

Url From my App

https://login.uber.com/oauth/v2/authorize?client_id=someId&response_type=code&scope=profile

Where client_Id was taken from dashboard in Uber.

Could please someone share the experience and maybe help with this issue.

After some researh, the problem was in creating the correct URL. Details and right information is provided on your dashboard.

See the dashboard example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM