1
votes

Getting auth token from uber is a two step process. Please refer Uber Auth API

  1. Ask the uber user to authorize : call GET https://login.uber.com/oauth/v2/authorize?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}

Provide your client_id and redirect_uri specific to your website. If the authorization is successful, you will be redirected to your site with the code in the query parameter.

  1. The the code you get in step 1 to retrieve auth token. Send an HTTP POST request to https://login.uber.com/oauth/v2/token. Following should be the json you send to server:

    { "client_secret": "{client_secret}", "client_id": "{client_id}", "grant_type": "{authorization_code}", "redirect_uri": "{redirect_uri}", "code": "{insert authorization code obtained in previous step}" }

In the step two I always get a error 400 with "invalid grant type" message. Please suggest where am I going wrong.

2

2 Answers

2
votes

You need to send the parameter as form-data, not JSON. Take a look at the curl example in section 3 here: https://developer.uber.com/docs/authentication

1
votes

The authorization and authentication documentation doesn't mention anything about JSON, therefore application/x-www-form-urlencoded media type is to be used to send the HTTP POST request to the /oauth/v2/token API endpoint