### Install and use Tesseral Go SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/quickstart.md This snippet shows how to install the Tesseral Go SDK using `go get`, integrate `auth.RequireAuth` middleware into an HTTP server, and access the organization ID from the request context. ```bash go get github.com/tesseral-labs/tesseral-sdk-go ``` ```go import "github.com/tesseral-labs/tesseral-sdk-go/auth" // before // http.ListenAndServe("...", server) // after http.ListenAndServe("...", auth.RequireAuth( server, auth.WithPublishableKey("publishable_key_..."), )) ``` ```go import "github.com/tesseral-labs/tesseral-sdk-go/auth" func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() fmt.Println("you work for:", auth.OrganizationID(ctx)) } ``` -------------------------------- ### Install Tesseral React SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/quickstart.md Installs the Tesseral React SDK using npm. This SDK provides hooks for user authentication and manages the redirection to the login page. ```bash npm install @tesseral/tesseral-react ``` -------------------------------- ### Install Tesseral Go SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/go.md Installs the Tesseral Go SDK using the go get command. This is the first step to integrating B2B authentication into your Golang application. ```bash go get github.com/tesseral-labs/tesseral-sdk-go ``` -------------------------------- ### Install and use Tesseral Flask SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/quickstart.md This snippet demonstrates how to install the Tesseral Flask SDK using pip, apply the `require_auth` decorator to Flask routes, and retrieve the organization ID. ```bash pip install tesseral-flask ``` ```python from flask import Flask from tesseral_flask import require_auth app = Flask(__name__) app.before_request(require_auth(publishable_key="publishable_key_...")) ``` ```python from tesseral_flask import organization_id organization_id() # returns a string like "org_..." ``` -------------------------------- ### Golang Quickstart for B2B Auth Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/what-is-tesseral.md This snippet provides a quickstart guide for adding B2B authentication to a Golang application using Tesseral. It highlights the ease of integrating auth features with minimal code. ```Golang Add B2B auth support to your Golang app in just a few lines of code. ``` -------------------------------- ### Install and use Tesseral Express.js SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/quickstart.md This snippet shows how to install the Tesseral Express.js SDK using npm, add the `requireAuth` middleware to an Express app, and access the organization ID from requests. ```bash npm install @tesseral/tesseral-express ``` ```typescript import express from "express"; import { requireAuth } from "@tesseral/tesseral-express"; const app = express(); // before // app.listen(...) // after app.use( requireAuth({ publishableKey: "publishable_key_...", }), ); app.listen(8080, "localhost", () => { console.log("Listening on http://localhost:8080"); }); ``` ```typescript import { organizationId } from "@tesseral/tesseral-express"; app.get("/", (req, res) => { console.log(`you work for ${organizationId(req)}`) }); ``` -------------------------------- ### React Quickstart for B2B Auth Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/what-is-tesseral.md This snippet provides a quickstart guide for adding B2B authentication support to a React application using Tesseral. It aims to simplify the integration process with minimal code. ```React Add B2B auth support to your React app in just a few lines of code. ``` -------------------------------- ### Enable API Keys in Go Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This Go code snippet demonstrates enabling API Key authentication by passing `auth.WithEnableAPIKeys()` to `auth.RequireAuth`. Ensure you have completed the Go Quickstart Guide. ```go http.ListenAndServe("...", auth.RequireAuth( server, auth.WithPublishableKey("publishable_key_..."), auth.WithEnableAPIKeys(), )) ``` -------------------------------- ### Express.js Quickstart for B2B Auth Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/what-is-tesseral.md This snippet offers a quickstart guide for integrating B2B authentication into an Express.js application with Tesseral. It focuses on enabling auth features with a small amount of code. ```Express.js Add B2B auth support to your Express.js app in just a few lines of code. ``` -------------------------------- ### Enable API Keys in FastAPI Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This example shows how to enable API Key authentication in a FastAPI application by passing `api_keys_enabled=True` to the `RequireAuthMiddleware`. Consult the FastAPI Quickstart Guide for prerequisites. ```python app.add_middleware( RequireAuthMiddleware, publishable_key="publishable_key_...", api_keys_enabled=True, ) ``` -------------------------------- ### Install Tesseral Flask SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/python/flask.md Install the Tesseral Flask SDK using pip. This command fetches and installs the necessary package for your Python environment. ```bash pip install tesseral-flask ``` -------------------------------- ### Build tesseral-api Binary with Go Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Instructions to build the tesseral-api binary for your operating system and architecture. This requires having Go installed. ```Bash go build -o tesseral-api . ``` -------------------------------- ### Example User Invite ID Format Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/user-invites.md This example shows the typical format of a User Invite ID in Tesseral, which always starts with the prefix 'user_invite_'. ```Text user_invite_17x0k5o5aei5pqbfdaerlcjyc ``` -------------------------------- ### Enable API Keys in Flask Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This code demonstrates how to enable API Key authentication in a Flask application by passing `enable_api_keys=True` to the `require_auth` function. Refer to the Flask Quickstart Guide for initial setup. ```python app.before_request( require_auth( publishable_key="publishable_key_...", enable_api_keys=True, ) ) ``` -------------------------------- ### Install Tesseral Svelte SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/clientside/svelte.md Installs the Tesseral Svelte SDK using npm. This is the first step to integrating B2B authentication into your Svelte application. ```bash npm install @tesseral/tesseral-svelte ``` -------------------------------- ### Enable API Keys in Axum Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This Rust code shows how to enable API Key authentication in Axum by calling `with_api_keys_enabled(true)` on the `Authenticator`. Refer to the Axum Quickstart Guide for setup. ```rust let authenticator = Authenticator::new("publishable_key_...".into()) .with_api_keys_enabled(true); let app: Router = Router::new() .route("/", get(handler)) .layer(require_auth(authenticator)); ``` -------------------------------- ### Install Tesseral Next.js SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/nextjs.md Installs the `@tesseral/tesseral-nextjs` package into your Next.js project using npm. ```bash npm install @tesseral/tesseral-nextjs ``` -------------------------------- ### Example Configuration URL Format for Okta Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/oidc-connections.md Shows the typical structure of a configuration URL for Okta, including the well-known path and parameters. ```URL https:///.well-known/openid-configuration?client_id= ``` -------------------------------- ### Install Tesseral FastAPI SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/python/fastapi.md Install the Tesseral FastAPI SDK using pip. This command is used to add the necessary library to your Python project's environment. ```bash pip install tesseral-fastapi ``` -------------------------------- ### Install Tesseral React SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/clientside/react.md Install the Tesseral React SDK using npm. This command is used to add the necessary package to your project's dependencies. ```bash npm install @tesseral/tesseral-react ``` -------------------------------- ### Flask Quickstart for B2B Auth Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/what-is-tesseral.md This snippet serves as a quickstart for implementing B2B authentication in a Flask application using Tesseral. It emphasizes a concise code implementation for adding auth capabilities. ```Flask Add B2B auth support to your Flask app in just a few lines of code. ``` -------------------------------- ### Example Okta Client ID Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/oidc-connections.md Provides an example of what a Client ID from Okta might look like. ```Plain Text 0oaslm6zmp95K2c5F697 ``` -------------------------------- ### Perform TesseralDB Migrations Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Prepares the database tables for tesseraldb by applying migrations. This requires installing golang-migrate and running the migrate command with the appropriate database connection string. ```bash migrate -path cmd/openauthctl/migrations -database "postgres://..." up ``` -------------------------------- ### Create Audit Log Event in Next.js Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/audit-logs/audit-logs-tutorial.md This TypeScript example demonstrates creating an audit log event in a Next.js application using the Tesseral Node.js SDK. It shows how to initialize the client, get credentials from the request, and log an event. ```typescript import { TesseralClient } from "@tesseral/tesseral-node"; import { auth } from "@tesseral/tesseral-nextjs/serverside"; import { NextRequest } from "next/server"; // Assuming tesseralClient is initialized globally or passed appropriately // const tesseralClient = new TesseralClient(); // export async function POST(request: NextRequest) { // const { credentials } = await auth({ or: "throw" }); // // ... // tesseralClient.auditLogEvents.createAuditLogEvent({ // auditLogEvent: { // credentials: credentials, // eventName: "acme.expense_reports.approve", // eventDetails: { // "expenseReportId": "expense_report_123", // } // } // }) // // ... // } ``` -------------------------------- ### Enable API Keys in Next.js Environment Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This configuration shows how to enable API Key authentication in Next.js by setting the environment variable `TESSERAL_AUTH_ENABLE_API_KEYS` to `1` in your `.env` file. Follow the Next.js Quickstart Guide for integration. ```txt TESSERAL_AUTH_ENABLE_API_KEYS=1 ``` -------------------------------- ### Install Tesseral Django SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/python/django.md Install the Tesseral Django SDK using pip. This command fetches and installs the necessary package for your Python environment. ```bash pip install tesseral-django ``` -------------------------------- ### Install Tesseral Express SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/node/express.md Install the Tesseral Express SDK using npm. This is the first step to integrating B2B authentication into your Express.js application. ```bash npm install @tesseral/tesseral-express ``` -------------------------------- ### Example Okta Client Secret Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/oidc-connections.md Demonstrates the format of a Client Secret obtained from Okta. ```Plain Text Hgb1yBRQBKTzydA1nyFKH6FZ7rxJv8ZJ4dD-zuLkYA2TbqD2z1AJt8wWaxYhzzDh ``` -------------------------------- ### Public Key Example (PEM format) Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/passkeys.md Shows an example of a public key stored in PEM format, associated with a Passkey. This key is used to verify authentication assertions from the user's device. ```text -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A... -----END PUBLIC KEY----- ``` -------------------------------- ### Enable API Keys in Django Settings Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This configuration snippet illustrates how to enable API Key authentication in a Django project by setting `TESSERAL_API_KEYS_ENABLED` to `True` in your Django settings. Make sure to follow the Django Quickstart Guide. ```python MIDDLEWARE = [ # ... 'tesseral_django.middleware.AuthMiddleware', # ... ] TESSERAL_PUBLISHABLE_KEY = "publishable_key_..." TESSERAL_API_KEYS_ENABLED = True ``` -------------------------------- ### Build Vault UI Static Files Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Builds the static files for the vault-ui application. This involves navigating to the vault-ui directory, installing dependencies, and running the build script. ```bash cd vault-ui npm ci npm run build ``` -------------------------------- ### Example Redirect URL Format Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/oidc-connections.md Illustrates the format of a Tesseral redirect URL, which can include a custom Vault Domain. ```URL https://vault.app.myapp.com/api/oidc/v1/oidc_connection_.../callback ``` -------------------------------- ### Add TesseralProvider to React App Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/quickstart.md Integrates the TesseralProvider component into the root of a React application. This component requires a publishable key and enables automatic redirection to the Tesseral login flow for unauthenticated users. ```typescript import { createRoot } from "react-dom/client"; import { TesseralProvider } from "@tesseral/tesseral-react"; const root = createRoot(...); root.render( // use the publishable_key_... you got in Step 2 ); ``` -------------------------------- ### Google UserInfo Response Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/technical-concepts/log-in-with-google/index.md Example JSON response from Google's userinfo endpoint, containing user details like sub, name, email, and picture. ```json { "sub": "...", "name": "Ulysse Carion", "given_name": "Ulysse", "family_name": "Carion", "picture": "https://...", "email": "ulyssecarion@gmail.com", "email_verified": true, "locale": "en" } ``` -------------------------------- ### Passkey ID Example Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/passkeys.md Demonstrates the format of a unique Passkey identifier within Tesseral. Passkey IDs always begin with the prefix 'passkey_'. ```text passkey_2mk0zv3qt9fdn2d5gq8ae13yh ``` -------------------------------- ### Get Organization Settings URL in Svelte Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/clientside/svelte.md Provides a link to the self-serve organization settings UI via `getOrganizationSettingsUrl`. This enables management of collaborators, invites, and login methods. ```typescript Organization Settings ``` -------------------------------- ### Initialize Tesseral Project with Bootstrap Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Initializes a 'dogfood' project after running database migrations. This command sets up the initial project for authenticating users in the Tesseral Console. It requires database connection details, a root user email, KMS key IDs, and domain information. ```bash go run ./cmd/openauthctl bootstrap \ --database "postgres://..." \ --root-user-email "root@example.com" \ --session-kms-key-id "..." \ --console-domain "..." \ --vault-domain "..." ``` -------------------------------- ### Switch to Production Publishable Keys Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/quickstart.md To deploy your application to production, you must use the publishable keys associated with your production Tesseral project instead of the sandbox keys. This is the primary code modification required for production deployment. ```javascript // Replace with your production publishable key const tesseralPublishableKey = "pk_production_..."; ``` -------------------------------- ### Enable API Keys in Express.js Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/api-keys/api-keys-tutorial.md This snippet shows how to enable API Key authentication in an Express.js application by passing `enableApiKeys: true` to the `requireAuth` function. Ensure you have followed the Express.js Quickstart Guide. ```typescript app.use( requireAuth({ publishableKey: "publishable_key_...", enableApiKeys: true, }), ); ``` -------------------------------- ### Create Audit Log Event in Go Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/audit-logs/audit-logs-tutorial.md This Go code example shows how to create an audit log event using the Tesseral Go SDK. It includes setting up the client, creating an AuditLogEvent struct with event name, actor credentials, and details, and then calling the CreateAuditLogEvent method. ```go import ( "context" "net/http" "github.com/tesseral-labs/tesseral-sdk-go" "github.com/tesseral-labs/tesseral-sdk-go/auth" "github.com/tesseral-labs/tesseral-sdk-go/client" ) // Assuming tesseralClient is initialized elsewhere // var tesseralClient *client.Client // func ApproveExpenseReport(w http.ResponseWriter, r *http.Request) { // // ... // tesseralClient.AuditLogEvents.CreateAuditLogEvent(r.Context(), &tesseral.AuditLogEvent{ // EventName: tesseral.String("acme.expense_reports.approve"), // ActorCredentials: tesseral.String(auth.Credentials(r.Context())), // EventDetails: map[string]any{ // "expenseReportId": "expense_report_123", // }, // }) // // ... // } ``` -------------------------------- ### Access Frontend API with Tesseral React SDK Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/frontend-api-reference/index.md Demonstrates how to access the Frontend API client from the Tesseral React SDK using the `useTesseral` hook. It shows an example of calling the `whoami` method to get user information. ```typescript import { useTesseral } from "@tesseral/tesseral-react"; async function example() { const { frontendApiClient } = useTesseral(); console.log(await frontendApiClient.me.whoami()); } ``` -------------------------------- ### Express.js: Check User Permissions Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/rbac/rbac-tutorial.md This snippet demonstrates how to use the `hasPermission` function from the Tesseral Express.js SDK to check if a user has the necessary permissions to perform a specific action. Ensure you have followed the Express.js Quickstart Guide for Tesseral. ```typescript import { hasPermission } from "@tesseral/tesseral-express"; app.get("/api/widgets/delete", (req, res) => { if (!hasPermission(req, "acme.widgets.delete")) { // ... } // ... }); ``` -------------------------------- ### Build Console Single-Page Application Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Builds the static files for the console single-page application. This requires running tesseral-bootstrap first to initialize a dogfood project. Then, install dependencies and build the application, specifying the dogfood project ID. ```bash cd console npm ci # Replace project_... with the project ID outputted by tesseral-bootstrap CONSOLE_DOGFOOD_PROJECT_ID=project_... npm run build ``` -------------------------------- ### Configure Go SDK for Self-Hosted Tesseral Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Provides an example of configuring the Tesseral Go SDK to connect to a self-hosted Tesseral instance. It demonstrates using `tesseraloptions.WithBaseURL` to set the custom API endpoint when creating a new `tesseralClient`. ```go import ( tesseraloptions "github.com/tesseral-labs/tesseral-sdk-go/options" tesseralclient "github.com/tesseral-labs/tesseral-sdk-go/client" ) tesseralClient := tesseralclient.NewClient( tesseraloptions.WithBaseURL("https://api.tesseral-self-hosted.example.com/"), // ... ) ``` -------------------------------- ### Flask: Check User Permissions Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/rbac/rbac-tutorial.md This snippet shows how to implement permission checks in a Flask backend using the Tesseral SDK. It assumes you have completed the Flask Quickstart Guide for Tesseral. You would typically use a function similar to `hasPermission` to verify user actions. ```python # Example placeholder for Flask permission check # from tesseral_flask import has_permission # @app.route('/api/widgets/delete') # def delete_widget(): # if not has_permission(request, "acme.widgets.delete"): # # ... handle unauthorized access # # ... proceed with widget deletion ``` -------------------------------- ### Enable OIDC on Tesseral Project Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/oidc/oidc-tutorial.md This section describes the steps to enable OIDC authentication for a Tesseral project. It involves navigating to the Tesseral Console's Authentication page and configuring enterprise settings. ```bash Go to the [Authentication](https://console.tesseral.com/settings/authentication) page in the Tesseral Console and click on **Configure Enterprise Settings**. Then enable **Log in with OIDC**. Click **Save changes**. ``` -------------------------------- ### Automate SCIM Enablement with Tesseral Backend API Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/scim/scim-tutorial.md This snippet demonstrates how to use the Tesseral Backend API's UpdateOrganization endpoint to automate the process of enabling SCIM for an organization. This is useful for managing SCIM settings programmatically across multiple organizations. ```HTTP PUT /organizations/{organization_id} Content-Type: application/json { "scim_enabled": true, "scim_allowed_domains": ["customerdomain.com"] } ``` -------------------------------- ### Build Tesseral API Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Builds the Tesseral API binary. Ensure GOOS and GOARCH are set appropriately for your target environment. The resulting binary is named 'api'. ```bash go build -o api ./cmd/api ``` -------------------------------- ### Example Organization ID Format Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/user-invites.md This example illustrates the format of an Organization ID in Tesseral, which is used to scope User Invites. It is referenced in the Backend API as 'organizationId'. ```Text org_c07mn4m95d0y443zarb4oq0zl ``` -------------------------------- ### Example Incremental Authorization URL Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/technical-concepts/log-in-with-google/index.md This URL demonstrates how to request additional Gmail send permissions using incremental authorization. It includes `prompt=consent` to ensure the user sees the consent screen and `include_granted_scopes=true` to retain previously granted scopes. ```txt https://accounts.google.com/o/oauth2/v2/auth ?client_id=... &response_type=code &state=... &redirect_uri=... &prompt=consent &include_granted_scopes=true &scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.send ``` -------------------------------- ### Create Organization with Python Backend API Key Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/concepts/backend-api-keys.md This Python code snippet demonstrates how to instantiate a Tesseral backend API client using an API key and then create a new Organization within the project associated with that key. It utilizes environment variables to securely fetch the API key. ```Python # instantiates a Tesseral backend API client using an API Key client = Tesseral(backend_api_key = os.getenv("TESSERAL_KEY")) # creates a new Organization within the Project that the API Key belongs to client.organizations.create_organization() ``` -------------------------------- ### Getting Organization ID from auth() (TypeScript) Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/nextjs.md Shows how to extract the `organizationId` from the result of the `auth()` function, which is crucial for B2B SaaS applications. ```ts import { auth } from "@tesseral/tesseral-nextjs/serverside"; const { organizationId } = await auth({ or: "throw" }); // returns a string like "org_..." ``` -------------------------------- ### Get Credentials in FastAPI Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/python/fastapi.md Retrieve credentials for internal service-to-service calls using the `credentials()` method. This value should not be logged or exposed externally. ```python from fastapi import FastAPI, Depends from tesseral_fastapi import Auth, get_auth @app.get("/credentials") async def get_credentials(auth: Auth = Depends(get_auth)): creds = auth.credentials() # Do not log or expose this value # Use it only for internal service-to-service calls return {"message": "Credentials retrieved"} ``` -------------------------------- ### Configure Node.js SDK for Self-Hosted Tesseral Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/features/self-hosting/index.md Shows how to configure the Tesseral Node.js SDK to connect to a self-hosted Tesseral instance by providing the `environment` parameter with the custom API URL when initializing the `TesseralClient`. ```typescript const client = new TesseralClient({ environment: "https://api.tesseral-self-hosted.example.com/", // ... }) ``` -------------------------------- ### Get User in Page Component (TypeScript/TSX) Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/nextjs.md Shows how to use the `getUser` function within a Next.js page component to access authentication information for server-side rendering. ```tsx import { getUser } from "@tesseral/tesseral-nextjs/serverside"; export default function Page() { // Server Action async function create() { "use server"; const user = await getUser(); // ... } // ... } ``` -------------------------------- ### Get User in Server Action (TypeScript) Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/nextjs.md Demonstrates how to import and use the `getUser` function from the Tesseral Next.js SDK within a server action to retrieve authentication details. ```ts "use server"; import { getUser } from "@tesseral/tesseral-nextjs/serverside"; export async function action() { const user = await getUser(); // ... } ``` -------------------------------- ### Update Organization SAML Configuration via API Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/saml/saml-tutorial.md This snippet demonstrates how to use the Tesseral Backend API to automate the process of enabling SAML for an organization. It specifically references the `UpdateOrganization` endpoint. ```HTTP POST /v1/organizations/{organizationId} { "samlEnabled": true } ``` -------------------------------- ### Get Organization Settings URL (Client-side) Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/nextjs.md Provides the `useOrganizationSettingsUrl` hook for client components to obtain a link to the organization settings UI, facilitating management of collaborators and invites. ```tsx "use client"; import { useOrganizationSettingsUrl } from "@tesseral/tesseral-nextjs/clientside"; export default function ClientComponent() { const organizationSettingsUrl = useOrganizationSettingsUrl(); return Organization Settings; } ``` -------------------------------- ### Publish Custom Audit Log Event with Django Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/audit-logs/audit-logs-tutorial.md This snippet provides the initial setup for publishing custom audit log events with Tesseral in a Django project. It shows how to instantiate the Tesseral client, with further implementation details expected for the `createAuditLogEvent` call. ```python from tesseral import Tesseral tesseral_client = Tesseral() # or AsyncTesseral() ``` ```python from django.http import HttpRequest from tesseral_django import credentials ``` -------------------------------- ### Get User Claims in FastAPI Source: https://github.com/tesseral-labs/docs/blob/main/fern/pages/sdks/serverside/python/fastapi.md Access details about the authenticated user, such as their email, using `access_token_claims()`. This method may raise `NotAnAccessTokenError` if the request is authenticated with an API key. ```python from fastapi import FastAPI, Depends from tesseral_fastapi import Auth, get_auth, NotAnAccessTokenError @app.get("/user") async def get_user(auth: Auth = Depends(get_auth)): try: claims = auth.access_token_claims() return {"user_email": claims.user.email} except NotAnAccessTokenError: return {"message": "Request authenticated with API key, not access token"} ```