Account Linking
¶ Overview
Account linking lets a user connect their Uber account to your product. The user signs in with Uber and approves access once. In return, your backend receives:
- A user access token and a refresh token, which authorize API calls on behalf of that user.
- The user’s Uber user ID, which you store against your own user record and send as
user_idin API requests.
Linking uses the OAuth 2.0 authorization code flow and takes four steps.
| Step | Call | What you get |
|---|---|---|
| 1 | GET https://auth.uber.com/oauth/v2/universal/authorize |
The user signs in and approves access |
| 2 | Redirect to your redirect URI | code |
| 3 | POST https://auth.uber.com/oauth/v2/token |
access_token, refresh_token |
| 4 | GET https://api.uber.com/v1.2/me |
rider_id, the user’s Uber user ID |
¶ Before You Start
You need the following on your application in the Uber Developer Dashboard:
- A client ID and client secret.
- A redirect URI. Uber sends the user back to this URI after they approve access. An
http://localhostURI can be registered for testing. - A privacy policy URL, shown to the user on the consent screen.
- The scopes below, enabled for the application.
| Scope | Why you need it |
|---|---|
<YOUR_PRODUCT_SCOPE> |
Access to the API on behalf of the user. Uber assigns this scope to your application. |
profile |
Required to read the user’s Uber user ID in Step 4. |
offline_access |
Returns a refresh token, so your backend can renew access without asking the user to sign in again. |
¶ Step 1 - Send the User to Uber
Build the authorize URL and open it from your app or website. Line breaks are added here for readability.
https://auth.uber.com/oauth/v2/universal/authorize
?client_id=<CLIENT_ID>
&response_type=code
&redirect_uri=<REDIRECT_URI>
&scope=<YOUR_PRODUCT_SCOPE>%20profile%20offline_access
&state=<STATE>
| Parameter | Required | Description |
|---|---|---|
client_id |
Y | The client ID of your application. |
response_type |
Y | Always code. |
redirect_uri |
Y | Must exactly match a redirect URI registered on your application. URL-encode the value. |
scope |
Y | The scopes to request, separated by spaces and URL-encoded (%20). Include profile & offline_access. |
state |
Y | A random, unguessable value that you generate for each attempt and store. Uber returns it unchanged in Step 2. |
prompt |
N | Set to consent to show the consent screen again. Useful while testing. |
Where the user signs in depends on their device:
- If an Uber app is installed, the link opens the Uber app.
- Otherwise, the link opens the default browser.
A user approves a given application and set of scopes only once. Later attempts with the same scopes skip the consent screen unless you send prompt=consent.
¶ Step 2 - Handle the Redirect
After the user approves, Uber redirects the browser to your redirect URI:
<REDIRECT_URI>?code=<AUTHORIZATION_CODE>&state=<STATE>
When your application receives the redirect:
- Compare
statewith the value you stored in Step 1. If they differ, stop and discard the response. - Read
codeand pass it to your backend. - Exchange the code right away. It is short-lived and can be used only once.
If the redirect has no code, do not continue. Check for an error parameter, which describes why the request was not completed.
¶ Step 3 - Exchange the Code for Access Token
Call the token endpoint from your backend.
| HTTP Method | POST |
| URL | https://auth.uber.com/oauth/v2/token |
| Content-Type | application/x-www-form-urlencoded |
| Parameter | Required | Description |
|---|---|---|
grant_type |
Y | Always authorization_code. |
client_id |
Y | The client ID of your application. |
client_secret |
Y | The client secret of your application. |
code |
Y | The authorization code from Step 2. |
redirect_uri |
Y | The same redirect URI you sent in Step 1. |
scope |
N | The same scope you sent in Step 1. |
Example request
curl -X POST "https://auth.uber.com/oauth/v2/token" \
-d "grant_type=authorization_code" \
-d "client_id=<CLIENT_ID>" \
-d "client_secret=<CLIENT_SECRET>" \
-d "code=<AUTHORIZATION_CODE>" \
--data-urlencode "redirect_uri=<REDIRECT_URI>" \
-d scope="<YOUR_PRODUCT_SCOPE> profile offline_access"
Example response
{
"access_token": "<ACCESS_TOKEN>",
"token_type": "Bearer",
"expires_in": 2592000,
"refresh_token": "<REFRESH_TOKEN>",
"scope": "offline_access profile <YOUR_PRODUCT_SCOPE>"
}
| Field | Description |
|---|---|
access_token |
Send it as Authorization: Bearer <ACCESS_TOKEN> on API calls made on behalf of this user. |
token_type |
Always Bearer. |
expires_in |
Lifetime of the access token in seconds. 2592000 is 30 days. |
refresh_token |
Use it to get a new access token. See Keeping the Link Active. |
scope |
The scopes that were granted. Confirm that it includes profile before you continue. |
Store both tokens securely on your backend, against the user who linked their account.
¶ Step 4 - Get the User ID
Call the profile endpoint with the access token from Step 3.
| HTTP Method | GET |
| URL | https://api.uber.com/v1.2/me |
| Header | Authorization: Bearer <ACCESS_TOKEN> |
Example request
curl "https://api.uber.com/v1.2/me" \
-H "Authorization: Bearer <ACCESS_TOKEN>"
Example response
{
"uuid": "",
"rider_id": "<UBER_USER_ID>",
"first_name": "<FIRST_NAME>",
"last_name": "<LAST_NAME>",
"email": "<EMAIL>",
"picture": "<PICTURE_URL>",
"promo_code": "<PROMO_CODE>",
"mobile_verified": true
}
| Field | Description |
|---|---|
rider_id |
The user’s Uber user ID. Use this value as the user_id when an API request identifies the user. |
uuid |
Always empty. Use rider_id instead. |
Save rider_id against your own user record, together with the tokens from Step 3. The account is now linked.
¶ Keeping the Link Active
The access token expires after expires_in seconds. Renew it from your backend before then. The user does not need to do anything.
Example request
curl -X POST "https://auth.uber.com/oauth/v2/token" \
-d "grant_type=refresh_token" \
-d "client_id=<CLIENT_ID>" \
-d "client_secret=<CLIENT_SECRET>" \
-d "refresh_token=<REFRESH_TOKEN>"
The response has the same fields as in Step 3. Replace the tokens you stored with the ones in the response.
If the refresh call fails, the refresh token has expired or the user has revoked access. Ask the user to link their account again, starting from Step 1.
¶ Troubleshooting
| What you see | Likely cause | What to do |
|---|---|---|
GET /v1.2/me returns unauthorized with the message “This endpoint requires at least one of the following scopes: profile, …” |
The access token was issued without the profile scope. |
Add profile to scope in Step 1 and link again. Scopes are fixed when a token is issued. |
The redirect in Step 2 has an error and no code |
A requested scope is not enabled for your application, or redirect_uri does not match a registered URI. |
Request only scopes that are enabled for your application, and send the redirect URI exactly as registered. |
| The token call in Step 3 fails | The code has expired or was already used, or redirect_uri differs from the one sent in Step 1. |
Start again from Step 1 and exchange the new code right away. |
uuid is empty in the Step 4 response |
Expected. | Use rider_id. |