Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uber API | Requesting Access Token for Ride request returns 'invalid_grant' error

I want users to request Uber rides from my app.
https://developer.uber.com/docs/rides/authentication

Under OAuth 2.0 section at the above url, there are 6 steps :
1. Authorize (done)
2. Receive Redirect (done)
3. Get an Access Token ('invalid_grant' error)

The following screenshot is from Postman. I tried passing client_id, client_secret, grant_type, redirect_uri and code as params, form-data and x-www-form-url-encoded. But everytime it returns the same error.

enter image description here

I have put 'http://localhost:3000/auth/uber/callback' as redirect url in my Uber App dashboard.

I have even tried the following curl command in the terminal,but it returns the same 'invalid_grant' error

enter image description here

Can someone help me with this issue.

like image 868
TheGuy Avatar asked Oct 19 '22 06:10

TheGuy


1 Answers

Your postman request looks correct to me. My best guesses at whats going on:

1) You have multiple redirects set up, and you're using one redirect url when you do the authorization phase and a different one when you try and do token exchange

2) You're doing authorization for one client_id, and trying to do token exchange for another

3) You're authorization code has already been used / expired. Keep in mind its only good for one request.

Could you try the following and tell me what happens:

1) Do the authorization flow and pay special attention that the client id and redirect uri you put in your authorization URL are correct

2) After your browser redirects, copy the authorization code out of the redirect URL

3) Put the authorization code into the postman request / curl statement and make sure that the client id / redirect URI is correct when you do it.

like image 167
Richard Artoul Avatar answered Jan 04 '23 06:01

Richard Artoul