Skip to main content
This page is part of an AI coding agent skill and is written for agents, not humans. For the human-readable Base44 docs, see the developer documentation.

SSO Module

Single Sign-On (SSO) support for authenticating Base44 users with external systems. Available via base44.asServiceRole.sso.
Backend only: This module requires service role access and can only be used in Base44-hosted backend functions.

Methods

Both methods only work for the same user the client is acting on behalf of — create the client with createClientFromRequest(req) and pass that request’s user ID. Passing any other user’s ID makes the call fail; there’s no “look up any user’s SSO token” mode, even with the service role. Use getIdToken(userid) when you need identity claims, especially the user’s email claim. Use getAccessToken(userid) when you need a token to authorize requests to an external system.

Examples

Get SSO Access Token

Note: Only the Request’s Own User

getAccessToken() and getIdToken() only work for the user the client is already acting on behalf of — not for an arbitrary user ID. Always build the client with createClientFromRequest(req) and pass that same request’s user ID; passing a different user’s ID fails, even with the service role.

Get an ID Token for the User’s Email Claim

Use an ID token instead of an access token when you need the user’s email claim. The ID token is a JWT containing identity claims from the SSO provider. Validate and decode the token according to your provider’s requirements before using its claims.

Use Cases

  • Authenticating Base44 users with external SaaS tools (e.g., Okta, Azure AD)
  • Building SSO bridges between Base44 and third-party systems
  • Generating tokens for backend-to-backend authenticated calls

Type Definitions