Three lines

Uber

Developers

Authentication

Direct API にアクセスするには、OAuth サービスから有効なアクセストークンを取得する必要があります。https://api.uber.com/ へのすべてのコールには OAuth 2.0(client_credentials グラントタイプ)を利用します。

OAuth 2.0 の仕様は、RFC 6479 に記載されています

アクセストークンを取得する

アクセストークンを生成するには、アプリケーションの client_idclient_secretDirect ダッシュボードから取得します。

Direct ダッシュボード [開発者] タブ

認証リクエスト

認証エンドポイントでは、リクエストが application/x-www-form-urlencoded または multipart/form-data としてエンコードされることを想定しています。

ヘッダータイプ #1: application/x-www-form-urlencoded

curl --request POST 'https://auth.uber.com/oauth/v2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id=<CLIENT_ID>' \
--data-urlencode 'client_secret=<CLIENT_SECRET>' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=eats.deliveries'

ヘッダータイプ #2: multipart/form-data

curl --request POST 'https://auth.uber.com/oauth/v2/token' \
--header 'Content-Type: multipart/form-data' \
--form 'client_id="<CLIENT_ID>"' \
--form 'client_secret="<CLIENT_SECRET>"' \
--form 'grant_type="client_credentials"' \
--form 'scope="eats.deliveries"'
パラメータ 説明
client_id Direct ダッシュボードから取得したアプリケーションのクライアント ID。
client_secret アプリケーションのクライアントシークレット。これはアプリケーションのパスワードと同じように扱う必要があります。
grant_type Uber Direct API にアクセスするには、これを client_credentials グラントタイプに設定してアプリケーションを認証します。これにより、指定されたスコープで OAuth 2.0 アクセストークンが作成されます。
scope このトークンがアクセスできる Uber 開発者エンドポイントを指定します。Direct API の場合、スコープは常に eats.deliveries になります。Org API の場合、スコープは常に direct.organizations になります。
認証応答
{
  "access_token": "<TOKEN>",
  "expires_in": 2592000,
  "token_type": "Bearer",
  "scope": "eats.deliveries"
}

access_token フィールドには、Uber Direct API に対する認証に使用されるトークンが含まれます。

expires_in フィールドは、アクセストークンの有効期間を秒単位で示します。トークンは 30 日間(2,592,000 秒間)有効です。トークンは有効期限が切れるまで(またはその直前まで)、キャッシュして各リクエストで再利用できます。リクエストごとに生成し直す必要はありません。既存のトークンの更新はできませんが、必要に応じて何度でも新しいトークンを作成できます。

注:クライアント認証情報のグラントタイプのリクエストは、1 時間あたり 100 件のリクエストに制限されます。

Node.js と Python を使用したアクセストークンの取得例については、以下のリソースを参照してください。

Node.js の例
var request = require('request');

// Set the API endpoint and request options
var options = {
  method: 'POST',
  url: 'https://auth.uber.com/oauth/v2/token',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
  },
  form: {
    client_id: '<CLIENT_ID>', // Replace with your actual Client ID
    client_secret: '<CLIENT_SECRET>', // Replace with your actual Client Secret
    grant_type: 'client_credentials',
    scope: 'eats.deliveries', // The scope of access required
  },
};

// Send the request to Authorization API
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body); // Print the response body containing the access token
});
Python の例
import requests

url = "https://auth.uber.com/oauth/v2/token"

# Set the payload with required parameters
payload = {
    'client_id': '<CLIENT_ID>',         # Replace with your actual Client ID
    'client_secret': '<CLIENT_SECRET>', # Replace with your actual Client Secret
    'grant_type': 'client_credentials',
    'scope': 'eats.deliveries',         # The scope of access required
}

headers = {
  'Content-Type': 'application/x-www-form-urlencoded'
}

# Send the request to Authorization API
response = requests.post(url, headers=headers, data=payload)

print(response.text)  # Print the response text containing the access token
アクセストークンの用途

前の手順で返された access_token を、他の Direct API エンドポイントの Authorization ヘッダーのベアラートークンとして渡します。

Authentication(上述)以外のすべての Direct エンドポイントでは、リクエストが application/json としてエンコードされることを想定しています。以下の Create Quote API の curl の例を参照してください。

curl --request POST 'https://api.uber.com/v1/customers/<customer_id>/delivery_quotes' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <TOKEN>' \
--data-raw '{
    "pickup_address": "{\"street_address\": [\"20 W 34th St\", \"Floor 2\"],\"state\":\"NY\",\"city\":\"New York\",\"zip_code\":\"10001\",\"country\":\"US\"}",
  "dropoff_address": "{\"street_address\": [\"285 Fulton St\", \"\"],\"state\":\"NY\",\"city\":\"New York\",\"zip_code\":\"10006\",\"country\":\"US\"}"

}'
パラメータ 説明
customer_id 組織に固有の 128 ビットの UUID。Direct ダッシュボードの [開発者] タブにあります。
TOKEN 前の手順で返された access_token。Uber Direct API に対する認証に使用されます。
認証エラーコード
パラメータ 説明
invalid_request 必要なパラメータが指定されていません。
invalid_client 指定されたクライアント ID またはシークレットが無効です。
invalid_scope 指定されたスコープが無効です
server_error サーバーから不明なエラーが返されました。
unauthorized 提供された OAuth 2.0 の認証情報が無効です。

Uber

Developers
© 2025 Uber Technologies Inc.