Skip to main content

Overview

Principal sessions allow end-users to view and manage their grants through a dashboard. Create a session to generate a short-lived JWT and dashboard URL.

Create

session, err := client.PrincipalSessions.Create(ctx, grantex.CreatePrincipalSessionParams{
    PrincipalID: "user-123",
    ExpiresIn:   "1h",
})
fmt.Printf("Dashboard: %s\n", session.DashboardURL)

Parameters

ParameterTypeRequiredDescription
PrincipalIDstringYesThe user to create a session for
ExpiresInstringNoSession duration (default: "1h")

Response (PrincipalSessionResponse)

FieldTypeDescription
SessionTokenstringShort-lived JWT for API access
DashboardURLstringURL to the permissions dashboard
ExpiresAtstringISO 8601 session expiry

Usage

Embed the dashboard URL in your application to let users manage their granted permissions:
session, _ := client.PrincipalSessions.Create(ctx, grantex.CreatePrincipalSessionParams{
    PrincipalID: currentUser.ID,
})
// Redirect or embed session.DashboardURL in an iframe