Authentication overview

The Uber Developer Platform provides access to various Uber services, allowing third-party applications to integrate functionalities such as requesting rides or deliveries. Authentication is a prerequisite for any application to interact with the Uber API on behalf of a user. The platform primarily utilizes the OAuth 2.0 authorization framework, which is an industry-standard protocol for delegated authorization. This means applications do not handle user credentials directly but instead receive an access token after a user grants permission to the application.

OAuth 2.0 operates by establishing trust between the user, the application, and the Uber authorization server. When a user wishes to use an application that integrates with Uber, they are redirected to Uber's authentication portal to log in and authorize the application. Upon successful authorization, Uber issues an access token to the application, which then uses this token to make API requests on the user's behalf. This process ensures that user credentials remain secure with Uber and are never exposed to the third-party application.

For detailed information on configuring an application and managing credentials, developers should refer to the Uber API authentication guide. The platform maintains specific requirements for redirect URIs and scopes to ensure secure integration and prevent unauthorized access.

Supported authentication methods

Uber's Developer Platform leverages standard authentication methods to secure API access. The primary method is OAuth 2.0, which supports various grant types depending on the application architecture.

OAuth 2.0 Authorization Code Grant

This is the recommended and most common grant type for web and mobile applications. It involves a multi-step process:

  1. The application redirects the user to Uber's authorization endpoint.
  2. The user logs in to their Uber account and grants permission to the application for requested API scopes.
  3. Uber redirects the user back to the application's pre-registered redirect URI with an authorization code.
  4. The application exchanges this authorization code for an access token and a refresh token by making a server-side request to Uber's token endpoint, using its client ID and client secret.
  5. The application uses the access token to make authenticated API requests.

This method is considered secure because the authorization code is exchanged for tokens server-side, preventing tokens from being exposed in the user's browser or mobile client. The IETF RFC 6749 provides the foundational specification for the OAuth 2.0 authorization code grant.

Token types

  • Access Token: A short-lived credential that authorizes requests to the Uber API on behalf of a specific user. It is sent in the Authorization header as a Bearer token (e.g., Authorization: Bearer <access_token>).
  • Refresh Token: A long-lived credential used to obtain new access tokens once the current one expires, without requiring the user to re-authorize the application. Refresh tokens should be stored securely on the application's server.

Authentication methods summary

Method When to Use Security Level
OAuth 2.0 Authorization Code Grant Web applications, mobile applications (iOS, Android) High (prevents direct credential exposure, uses server-side token exchange)
Bearer Token (Access Token) API requests after authorization High (when used over HTTPS/TLS and securely managed)
Refresh Token Renewing expired access tokens High (requires secure server-side storage)

Getting your credentials

To begin integrating with the Uber API, developers must first register their application and obtain necessary credentials. This process typically involves creating a developer account and registering an application on the Uber Developer Dashboard.

  1. Create an Uber Developer Account: Navigate to the Uber Developer Portal and sign up or log in.
  2. Register a New Application: Within the developer dashboard, create a new application. During this process, you will typically provide details such as the application name, description, and importantly, the redirect URI(s).
  3. Obtain Client ID and Client Secret: Upon successful application registration, Uber will issue a unique Client ID and Client Secret.
    • Client ID: A public identifier for your application.
    • Client Secret: A confidential key that should be kept secure and never exposed in client-side code. It's used to authenticate your application when exchanging authorization codes for tokens.
  4. Configure Redirect URIs: Specify one or more valid redirect URIs in your application settings. These URIs are where Uber will send the user back after they authorize your application, along with the authorization code. Only pre-registered URIs are accepted, preventing redirection to unintended destinations.
  5. Request Scopes: Define the specific permissions (scopes) your application requires to access user data or perform actions. Examples include profile for user profile information or request_rides for ride booking functionality. Requesting only necessary scopes adheres to the principle of least privilege and enhances security.

It is crucial to store your Client Secret securely and never embed it directly in client-side code, such as in mobile apps or front-end JavaScript. For server-side applications, environment variables or secure configuration management systems are appropriate for storing sensitive credentials.

Authenticated request example

Once your application has obtained an access token, it can be used to make authenticated requests to the Uber API. Access tokens are typically included in the Authorization header of HTTP requests as a Bearer token.

Consider an example in Python using the requests library to fetch a user's profile information:


import requests

ACCESS_TOKEN = "<YOUR_ACCESS_TOKEN>"

headers = {
    "Authorization": f"Bearer {ACCESS_TOKEN}",
    "Accept-Language": "en_US",
    "Content-Type": "application/json"
}

response = requests.get("https://api.uber.com/v1.2/me", headers=headers)

if response.status_code == 200:
    user_profile = response.json()
    print("User Profile:", user_profile)
else:
    print(f"Error: {response.status_code} - {response.text}")

In this example:

  • <YOUR_ACCESS_TOKEN> should be replaced with the actual access token obtained through the OAuth 2.0 flow.
  • The Authorization: Bearer header is essential for authenticating the request.
  • The endpoint https://api.uber.com/v1.2/me is used to retrieve the authenticated user's profile.

For Node.js, a similar approach would involve using a library like axios:


const axios = require('axios');

const ACCESS_TOKEN = "<YOUR_ACCESS_TOKEN>";

async function getUserProfile() {
    try {
        const response = await axios.get('https://api.uber.com/v1.2/me', {
            headers: {
                'Authorization': `Bearer ${ACCESS_TOKEN}`,
                'Accept-Language': 'en_US',
                'Content-Type': 'application/json'
            }
        });
        console.log('User Profile:', response.data);
    } catch (error) {
        console.error(`Error: ${error.response.status} - ${error.response.data}`);
    }
}

getUserProfile();

These examples demonstrate the fundamental structure for making authenticated API calls after successfully acquiring an access token.

Security best practices

Adhering to security best practices is critical when integrating with the Uber API to protect user data and maintain the integrity of your application. The following guidelines are recommended:

  • Secure OAuth 2.0 Implementation: Always use the Authorization Code Grant flow for web and mobile applications. Avoid implicit grant flows, which are less secure as they expose tokens in the browser's URL fragment. Implement Proof Key for Code Exchange (PKCE) for public clients (mobile and native apps) to mitigate authorization code interception attacks.
  • Protect Client Secret: The Client Secret is a sensitive credential. Store it securely on your server, preferably using environment variables or a dedicated secrets management service. Never embed the Client Secret directly in client-side code (e.g., JavaScript, mobile app binaries) or commit it to version control systems.
  • HTTPS/TLS Everywhere: All communication with the Uber API, including authorization redirects and token exchanges, must occur over HTTPS/TLS. This encrypts data in transit, protecting against eavesdropping and man-in-the-middle attacks.
  • Validate Redirect URIs: Rigorously configure and validate your redirect URIs in the Uber Developer Dashboard. Ensure they are specific and do not use wildcard patterns unless absolutely necessary and securely managed.
  • Least Privilege Principle: Request only the minimum necessary API scopes for your application's functionality. Over-requesting scopes can increase the attack surface and diminish user trust. Regularly review and update requested scopes as your application evolves.
  • Secure Token Storage: Access tokens and especially refresh tokens must be stored securely. For refresh tokens, store them in a secure, server-side database with appropriate encryption and access controls. Avoid storing them in local storage, session storage, or cookies on the client side.
  • Token Expiration and Renewal: Design your application to handle access token expiration gracefully. Use refresh tokens to obtain new access tokens when they expire, minimizing the need for users to re-authorize. Revoke refresh tokens if compromised or if a user explicitly disconnects your application.
  • Error Handling and Logging: Implement robust error handling and logging for authentication failures. Monitor for unusual activity or repeated failed authentication attempts, which could indicate malicious activity.
  • Regular Security Audits: Periodically review your application's authentication implementation and overall security posture. Stay informed about security updates and best practices from Uber and the broader security community.