Reputation: 108
Getting auth token from uber is a two step process. Please refer Uber Auth API
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.
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.
Upvotes: 1
Views: 1436
Reputation: 6557
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
Upvotes: 1
Reputation: 346
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
Upvotes: 2