> ## 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.

# Modulo SSO

> Supporto Single Sign-On (SSO) per autenticare gli utenti Base44 con sistemi esterni. Disponibile tramite base44.asServiceRole.sso.

<Warning>
  Questa pagina fa parte di una skill per agenti IA di programmazione ed è scritta per gli agenti, non per gli umani. Per la documentazione Base44 leggibile dagli umani, consulta la [documentazione per sviluppatori](/developers).
</Warning>

# Modulo SSO

Supporto Single Sign-On (SSO) per autenticare gli utenti Base44 con sistemi esterni. Disponibile tramite `base44.asServiceRole.sso`.

> **Solo backend**: questo modulo richiede l'accesso service role e può essere usato solo nelle funzioni backend ospitate da Base44.

## Metodi

| Metodo                   | Firma                             | Descrizione                                             |
| ------------------------ | --------------------------------- | ------------------------------------------------------- |
| `getAccessToken(userId)` | `Promise<SsoAccessTokenResponse>` | Ottiene un token di accesso SSO per un utente specifico |

## Esempi

### Ottenere un token di accesso 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 });
});
```

### Ottenere un token per un utente specifico (service role)

```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 });
});
```

## Casi d'uso

* Autenticare utenti Base44 con strumenti SaaS esterni (ad esempio Okta, Azure AD)
* Creare bridge SSO tra Base44 e sistemi di terze parti
* Generare token per chiamate autenticate backend-to-backend

## Definizioni dei tipi

```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>Questa pagina è stata tradotta utilizzando l'IA. Per informazioni più accurate e aggiornate, consulta la [versione inglese](/). </Note>
