For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sign In With Roboflow(開発者リファレンス)

Sign in with Roboflow の OAuth リファレンス、表示設定、エラー、サンプルアプリ。

Roboflow でサインインを使用するアプリ向けのリファレンス。アプリの登録、PKCE、認可フローについては、以下を参照してください Roboflowでサインイン(はじめに).

サンプルアプリ

roboflow/siwr_example_app は、次に対して完全な OAuth フローを実行する小さな Node.js アプリです app.roboflow.com および api.roboflow.com。トークンは Express セッション内に保持され、ブラウザにクライアントシークレットが見えることはありません。

git clone https://github.com/roboflow/siwr_example_app.git
cd siwr_example_app
cp .env.example .env
# RF_CLIENT_ID、RF_CLIENT_SECRET、SESSION_SECRET を設定
npm install && npm run dev

リダイレクト URI を指定して OAuth アプリを登録する http://localhost:3001/oauth/callback およびアプリが使用するスコープ(openid, profile, email, workspace:read, project:read, model:infer).

ルート
目的

GET /

ランディングページ、またはサインイン後のダッシュボード

GET /oauth/start

PKCE リダイレクトで OAuth を開始

GET /oauth/callback

コードを交換してダッシュボードを表示

POST /logout

トークンを失効させ、セッションをクリア

PKCE と認可 URL

以下より src/oauth.ts:

export function pkcePair(): { verifier: string; challenge: string } {
    const verifier = crypto.randomBytes(48).toString("base64url");
    const challenge = crypto.createHash("sha256").update(verifier).digest("base64url");
    return { verifier, challenge };
}

export function buildAuthorizeUrl(state: string, codeChallenge: string): string {
    const url = new URL(`${config.appHost}/oauth/authorize`);
    url.searchParams.set("response_type", "code");
    url.searchParams.set("client_id", config.clientId);
    url.searchParams.set("redirect_uri", config.redirectUri);
    url.searchParams.set("scope", REQUESTED_SCOPE_STRING);
    url.searchParams.set("state", state);
    url.searchParams.set("code_challenge", codeChallenge);
    url.searchParams.set("code_challenge_method", "S256");
    return url.toString();
}

GET /oauth/start 保存する 検証子 および state をセッションに保存し、その後このURLにリダイレクトします。

コールバックと state の確認

以下より src/server.ts:

コードを交換する前に、一度しか使えない OAuth セッションデータを必ず削除してください。 exchangeCodeForTokens code、 redirect_uri, code_verifier、client ID と client secret を トークンエンドポイント.

トークンエンドポイント認証

Workspace OAuth アプリは confidential client です。トークン、revoke、introspect エンドポイントへの各呼び出しには client secret が含まれます。アプリを「Workspace Settings > Developer」で作成または編集するときは、クライアントまたはゲートウェイに合った方式を選択してください。

方式
動作

client_secret_post

送信 client_id および client_secret をリクエスト本文のフォームフィールドとして送信します。既定値です。

client_secret_basic

HTTP を送信 Authorization: Basic ヘッダーに、base64 エンコードされた client_id:client_secretを含め、両方を本文から除外します。

MCP コネクタのように自ら登録するパブリッククライアントは、 client_id のみを送信し、PKCE に依存します。

ホスト

サービス
ベース URL

サインイン、トークン、OIDC

https://app.roboflow.com

REST API

https://api.roboflow.com

公開範囲

どのワークスペースがあなたの OAuth アプリでサインインできるかを制御します。

ダッシュボードのオプション
サインインできるユーザー

内部

アプリを作成したワークスペースのメンバーのみ

非公開

あなたの client ID を持つすべてのワークスペース

公開

非公開と同じに加え、機能が有効な場合は「Sign in with Roboflow」ディレクトリに掲載されます

「External」に相当する別の公開範囲タイプはありません。ワークスペースをまたぐ統合には「非公開」を使用します。

各顧客ワークスペースでは、External OAuth apps ポリシーも設定できます。すべて許可、一覧表示された client ID のみ許可、またはすべてブロックです。ワークスペース外でサインインに失敗する場合は、顧客に対し、ワークスペース設定であなたの client ID を許可するよう依頼してください。

エンドポイント

すべてのサインインおよびトークンエンドポイントは app.roboflow.com.

目的
方式
URL

認可(ブラウザリダイレクト)

GET

/oauth/authorize

GET

/oauth/userinfo

GET

/oauth/validate

OIDC ディスカバリ

GET

/.well-known/openid-configuration

JWKS、検証用 id_token JWT

GET

/.well-known/jwks.json

トークンのイントロスペクト

クライアント資格情報を使用して、トークンが有効かどうかと付与内容を返します。クライアント資格情報なしでアクセストークンを確認するには、 トークンを検証する を使用してください。

Introspect a token

post

Returns whether a token is active and what it grants (RFC 7662). The client authenticates the same way as on the token endpoint. A public client can only introspect its own tokens. To check an access token without client credentials, use the validate endpoint instead.

認可
Authorizationstringオプション

client_secret_basic: your client ID as the username and client secret as the password. Use it only when your OAuth app is set to client_secret_basic. Otherwise send client_id and client_secret in the form body.

本文
tokenstring必須

An rfoa_ access token or rfor_ refresh token.

Example: rfoa_QWNjZXNzVG9rZW5FeGFtcGxl
token_type_hintstring · enumオプション

Which kind of token you are sending. Optional.

可能な値:
client_idstringオプション

Your client ID. Required unless you send it in the HTTP Basic header.

Example: YOUR_CLIENT_ID
client_secretstringオプション

Your client secret, for apps set to client_secret_post.

Example: rfcs_YOUR_CLIENT_SECRET
レスポンス
200

The token's state. An expired, revoked or unknown token returns only {"active": false}.

application/json
activeboolean必須

True when the token is live.

client_idstringオプション

The OAuth client the token was issued to.

substringオプション

The Roboflow user id.

scopestringオプション

Space-separated scopes.

expintegerオプション

Expiry time in seconds since the Unix epoch.

iatintegerオプション

Issue time in seconds since the Unix epoch.

issstringオプション
token_typestringオプション

Bearer for an access token.

workspace_idstringオプション

Workspace the token is bound to.

workspace_urlstringオプション

URL slug of that workspace.

post/oauth/introspect
POST /oauth/introspect HTTP/1.1
Host: app.roboflow.com
Authorization: Basic username:password
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 145

"token='rfoa_QWNjZXNzVG9rZW5FeGFtcGxl'&token_type_hint='access_token'&client_id='YOUR_CLIENT_ID'&client_secret='rfcs_YOUR_CLIENT_SECRET'"
{
  "active": true,
  "client_id": "YOUR_CLIENT_ID",
  "sub": "user_abc123",
  "scope": "openid workspace:read project:read",
  "exp": 1893456000,
  "iat": 1893452400,
  "iss": "https://app.roboflow.com",
  "token_type": "Bearer",
  "workspace_id": "5f3Tq8k2ZbW1aXyZ",
  "workspace_url": "your-workspace"
}

REST API でトークンを使用する

送信 Authorization: Bearer {access_token} から api.roboflow.com。参照: REST API で認証する.

よくあるエラー

レスポンス
意味
対処法

400 invalid_scope

要求されたスコープがアプリの「許可されたスコープ」リストにありません。

ダッシュボードでスコープを追加するか、リクエストから削除してください。

400 invalid_grant

code または refresh token が期限切れ、使用済み、または失効済みであるか、あるいはワークスペースがもはやあなたのアプリを許可していません。

ユーザーを再度サインインさせてください。

401 invalid_client

client ID または secret が間違っているか、secret が誤った方式で送信されています。

アプリのトークンエンドポイント認証設定を確認してください。

401 OAuthException で api.roboflow.com

アクセストークンが期限切れか、失効済みです。

1回更新してから、ユーザーを再度サインインさせてください。

404 GraphMethodException で api.roboflow.com

トークンにそのルートのスコープがないか、またはそのルートがトークンにバインドされていないワークスペースにあります。

必要なスコープでユーザーに再度同意してもらってください。

403 で api.roboflow.com

ユーザーの役割ではその操作を許可されていません。

ワークスペース管理者がユーザーの役割を変更します。

リダイレクトの不一致

redirect_uri が登録済みのリダイレクト URI と一致しません。

ダッシュボードの設定か認可 URL を修正してください。

セキュリティ

  • すべての認可リクエストで PKCE を使用してください。

  • 確認 state すべてのコールバックで。

  • 決して公開しない client_secret またはリフレッシュトークンをブラウザに公開しないでください。

  • ユーザーがサインアウトしたらトークンを失効させてください。

  • 必要なスコープだけを要求してください。完全な一覧は 利用可能なスコープ.

最終更新

役に立ちましたか?