> ## Documentation Index
> Fetch the complete documentation index at: https://docs.base44.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SSO モジュール

> Base44 ユーザーを外部システムで認証するためのシングルサインオン (SSO) サポート。`base44.asServiceRole.sso` 経由で利用可能。

<Warning>
  このページは AI コーディングエージェントスキルの一部で、人間ではなくエージェント向けに書かれています。人間向けの Base44 ドキュメントは [デベロッパードキュメント](/developers) を参照してください。
</Warning>

# SSO モジュール

Base44 ユーザーを外部システムで認証するためのシングルサインオン (SSO) サポート。`base44.asServiceRole.sso` 経由で利用可能。

> **バックエンドのみ**: このモジュールにはサービスロールアクセスが必要で、Base44 ホスト型バックエンド関数でのみ使用できます。

## メソッド

| メソッド                     | シグネチャ                             | 説明                       |
| ------------------------ | --------------------------------- | ------------------------ |
| `getAccessToken(userId)` | `Promise<SsoAccessTokenResponse>` | 特定のユーザーの SSO アクセストークンを取得 |

## 例

### SSO アクセストークンの取得

```javascript theme={null}
import { createClientFromRequest } from "npm:@base44/sdk";

Deno.serve(async (req) => {
  const base44 = createClientFromRequest(req);

  // Get the current user
  const user = await base44.auth.me();
  if (!user) {
    return Response.json({ error: "Unauthorized" }, { status: 401 });
  }

  // Get SSO access token for this user
  const { access_token } = await base44.asServiceRole.sso.getAccessToken(user.id);

  // Use the token to authenticate with an external system
  return Response.json({ ssoToken: access_token });
});
```

### 特定のユーザー用トークンの取得 (サービスロール)

```javascript theme={null}
Deno.serve(async (req) => {
  const base44 = createClientFromRequest(req);
  const { userId } = await req.json();

  // Get SSO token for any user (service role has access to all users)
  const { access_token } = await base44.asServiceRole.sso.getAccessToken(userId);

  return Response.json({ token: access_token });
});
```

## ユースケース

* Base44 ユーザーを外部 SaaS ツール (例: Okta、Azure AD) で認証する
* Base44 とサードパーティシステム間の SSO ブリッジを構築する
* バックエンド間の認証済み呼び出し用にトークンを生成する

## 型定義

```typescript theme={null}
/** Response from the SSO access token endpoint. */
interface SsoAccessTokenResponse {
  /** The SSO access token for the specified user. */
  access_token: string;
}

/** SSO module for managing SSO authentication (service role only). */
interface SsoModule {
  /**
   * Gets an SSO access token for a specific user.
   * @param userid - The Base44 user ID to get the SSO token for.
   * @returns Promise resolving to the SSO access token response.
   */
  getAccessToken(userid: string): Promise<SsoAccessTokenResponse>;
}
```

<Note>このページは AI を使用して翻訳されました。最も正確で最新の情報については、[英語版](/) を参照してください。 </Note>
