Reputation: 349
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:
The following screenshot is from Postman. I tried passing client_id, client_secret, grant_type, redirect_uri and code as parameters, form-data and x-www-form-url-encoded. But every time it returns the same error.
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.
Can someone help me with this issue?
Upvotes: 5
Views: 1321
Reputation: 346
Your Postman request looks correct to me. My best guesses at what's going on:
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
You're doing authorization for one client_id, and trying to do token exchange for another
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:
Do the authorization flow and pay special attention that the client id and redirect URI you put in your authorization URL are correct
After your browser redirects, copy the authorization code out of the redirect URL
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.
Upvotes: 3
Reputation: 1
Status Code: 401 Unauthorized
{
"error": "invalid_grant"
}
You are using an invalid refresh_token
. You can generate multiple
access tokens, but you can only use the latest generated
refresh_token
.
You supplied an invalid code
when exchanging an authorization code for an access_token
.
Upvotes: 0