### WithToken() Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example demonstrating the use of WithToken() for user and admin operations. ```Go // Basic flow client := gotrue.New(projectRef, anonKey) // Get access token from login tokenResp, err := client.SignInWithEmailPassword("user@example.com", "password") if err != nil { log.Fatal(err) } // Create authenticated client for user operations userClient := client.WithToken(tokenResp.AccessToken) user, err := userClient.GetUser() if err != nil { log.Fatal(err) } // Admin operations with service role adminClient := client.WithToken(serviceRoleToken) users, err := adminClient.AdminListUsers() if err != nil { log.Fatal(err) } // Refresh expired token newTokenResp, err := client.Token(types.TokenRequest{ GrantType: "refresh_token", RefreshToken: tokenResp.RefreshToken, }) if err != nil { log.Fatal(err) } // Use new token refreshedClient := client.WithToken(newTokenResp.AccessToken) ``` -------------------------------- ### Install Source: https://github.com/supabase-community/gotrue-go/blob/main/README.md Install the gotrue-go library using go get. ```sh go get github.com/supabase-community/gotrue-go ``` -------------------------------- ### Client Initialization Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example of initializing a GoTrue client with project reference and API key. ```Go package main import ( "log" "github.com/supabase-community/gotrue-go" ) func main() { projectRef := "your_project_ref" // From Supabase dashboard apiKey := "your_anon_key" // From Supabase dashboard client := gotrue.New(projectRef, apiKey) // Client is now ready to use settings, err := client.GetSettings() if err != nil { log.Fatal(err) } log.Printf("GoTrue Version: %s", settings.Description) } ``` -------------------------------- ### Usage Source: https://github.com/supabase-community/gotrue-go/blob/main/README.md Example of initializing the client and logging in a user to get access and refresh tokens. ```go package main import "github.com/supabase-community/gotrue-go" const ( projectReference = "" apiKey = "" ) func main() { // Initialise client client := gotrue.New( projectReference, apiKey, ) // Log in a user (get access and refresh tokens) resp, err := client.Token(gotrue.TokenRequest{ GrantType: "password", Email: "", Password: "", }) if err != nil { log.Fatal(err.Error()) } log.Printf("%+v", resp) } ``` -------------------------------- ### WithCustomGoTrueURL() Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Examples of configuring a custom GoTrue URL for different scenarios. ```Go // Standard Supabase setup client := gotrue.New(projectRef, anonKey) // Custom self-hosted GoTrue customClient := client.WithCustomGoTrueURL( "https://auth.company.internal/auth/v1", ) // Local development devClient := client.WithCustomGoTrueURL( "http://localhost:9999/auth/v1", ) // All requests now use the custom URL settings, err := customClient.GetSettings() ``` -------------------------------- ### AdminGenerateLink Example (Signup) Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of generating a signup link with custom data using AdminGenerateLink. ```go // Generate signup link with custom data signupLink, err := adminClient.AdminGenerateLink(types.AdminGenerateLinkRequest{ Type: types.LinkTypeSignup, Email: "newuser@example.com", Password: "initialPassword123", Data: map[string]interface{}{ "role": "team_lead", }, }) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Authorize Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of how to use the Authorize function to get an authorization URL and verifier. ```go authResp, err := client.Authorize(types.AuthorizeRequest{ Provider: types.ProviderGoogle, FlowType: types.FlowPKCE, Scopes: "email profile", }) if err != nil { log.Fatal(err) } // Redirect user to authResp.AuthorizationURL // After user authorizes, they'll be redirected back with a code // Use the returned Verifier for PKCE flow verification log.Printf("Redirect to: %s", authResp.AuthorizationURL) log.Printf("Keep verifier for callback: %s", authResp.Verifier) ``` -------------------------------- ### Example: Signing In with Email and Password Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example demonstrating how to sign in a user using their email and password. ```go tokenResp, err := client.SignInWithEmailPassword("user@example.com", "password123") if err != nil { log.Fatal(err) } log.Printf("Access Token: %s", tokenResp.AccessToken) log.Printf("User ID: %s", tokenResp.User.ID) ``` -------------------------------- ### AdminGetUser Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of how to use the AdminGetUser function to retrieve user information. ```go adminClient := client.WithToken(adminToken) userResp, err := adminClient.AdminGetUser(types.AdminGetUserRequest{ UserID: userID, }) if err != nil { log.Fatal(err) } log.Printf("User: %s, Email: %s, Created: %v", userResp.ID, userResp.Email, userResp.CreatedAt) ``` -------------------------------- ### Example: Creating a New Client Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example demonstrating how to create a new GoTrue client and make an API call. ```go package main import ( "log" "github.com/supabase-community/gotrue-go" ) func main() { client := gotrue.New("your_project_ref", "your_anon_key") // Now use client to make API calls user, err := client.GetUser() if err != nil { log.Fatal(err) } log.Printf("User: %+v", user) } ``` -------------------------------- ### Environment Configuration Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Demonstrates configuring gotrue-go from environment variables. ```go package main import ( "log" "os" "github.com/supabase-community/gotrue-go" ) func main() { projectRef := os.Getenv("SUPABASE_PROJECT_REF") apiKey := os.Getenv("SUPABASE_ANON_KEY") serviceRole := os.Getenv("SUPABASE_SERVICE_ROLE_KEY") customURL := os.Getenv("GOTRUE_URL") if projectRef == "" || apiKey == "" { log.Fatal("Missing required environment variables") } // Create base client client := gotrue.New(projectRef, apiKey) // Use custom URL if provided if customURL != "" { client = client.WithCustomGoTrueURL(customURL) } // Create admin client with service role if available var adminClient gotrue.Client if serviceRole != "" { adminClient = client.WithToken(serviceRole) } } ``` -------------------------------- ### Example: Using WithClient with a Custom HTTP Client Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example showing how to configure a custom HTTP client for all requests. ```go import "net/http" customHTTPClient := http.Client{ Timeout: time.Second * 30, } client := gotrue.New(projectRef, apiKey) client = client.WithClient(customHTTPClient) // All requests now use the custom HTTP client ``` -------------------------------- ### WithToken Example Source: https://github.com/supabase-community/gotrue-go/blob/main/README.md Example of using WithToken to create a client that uses a provided token in the Authorization header. ```go client := gotrue.New( projectRefernce, apiKey, ) token, err := client.Token(gotrue.TokenRequest{ GrantType: "password", Email: email, Password: password, }) if err != nil { // Handle error... } authedClient := client.WithToken( token.AccessToken, ) user, err := authedClient.GetUser() if err != nil { // Handle error... } ``` -------------------------------- ### Example: Using WithCustomGoTrueURL Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example demonstrating how to configure a custom GoTrue server URL. ```go client := gotrue.New(projectRef, apiKey) // Use a custom GoTrue deployment customClient := client.WithCustomGoTrueURL("https://auth.example.com/auth/v1") user, err := customClient.GetUser() if err != nil { log.Fatal(err) } ``` -------------------------------- ### Example - Custom Proxy Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Configures a custom proxy for the HTTP client. ```go import ( "net/http" "net/url" ) proxyURL, _ := url.Parse("http://proxy.company.internal:8080") transport := &http.Transport{ Proxy: http.ProxyURL(proxyURL), } httpClient := http.Client{ Transport: transport, Timeout: 10 * time.Second, } proxiedClient := client.WithClient(httpClient) ``` -------------------------------- ### Configuration Independence Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Demonstrates that configuration methods return copies, making clients independent. ```go // Create base client baseClient := gotrue.New(projectRef, anonKey) // Configure for user operations userClient := baseClient.WithToken(userToken) // Configure for admin operations (separate from userClient) adminClient := baseClient.WithToken(adminToken) // These are independent clients user, _ := userClient.GetUser() // Uses userToken admin, _ := adminClient.AdminListUsers() // Uses adminToken ``` -------------------------------- ### Example - Manual Redirect Handling Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example showing how to obtain the redirect URL without automatically following the redirect, allowing for manual handling. ```go // Get URL without following redirect ssoResp, err := client.SSO(types.SSORequest{ ProviderID: providerID, SkipHTTPRedirect: true, RedirectTo: "https://myapp.com/auth-callback", }) if err != nil { log.Fatal(err) } // Manually handle the redirect log.Printf("Redirect to: %s", ssoResp.URL) // Use the URL as needed ``` -------------------------------- ### PKCE Flow Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example demonstrating the PKCE flow for OAuth authorization, including initiating authorization, redirecting the user, handling the callback, and exchanging the code for a token. ```go // Step 1: Initiate authorization with PKCE authResp, err := client.Authorize(types.AuthorizeRequest{ Provider: types.ProviderGoogle, FlowType: types.FlowPKCE, Scopes: "openid email profile", }) if err != nil { log.Fatal(err) } // Store verifier for callback (typically in session/storage) storeVerifier(authResp.Verifier) // Step 2: Redirect user to authorization URL // In web: http.Redirect(w, r, authResp.AuthorizationURL, http.StatusFound) // In mobile: open URL in browser log.Printf("Redirect to: %s", authResp.AuthorizationURL) // Step 3: Handle callback (user is redirected back with ?code=...) code := getCodeFromCallback() // Extract from URL parameters verifier := getStoredVerifier() // Step 4: Exchange code for token tokenResp, err := client.Token(types.TokenRequest{ GrantType: "pkce", Code: code, CodeVerifier: verifier, }) if err != nil { log.Fatal(err) } // Step 5: Create authenticated client authedClient := client.WithToken(tokenResp.AccessToken) user, err := authedClient.GetUser() ``` -------------------------------- ### AdminGenerateLink Example (Recovery/Reset) Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of generating a recovery/reset password link using AdminGenerateLink. ```go adminClient := client.WithToken(adminToken) // Generate a recovery/reset password link linkResp, err := adminClient.AdminGenerateLink(types.AdminGenerateLinkRequest{ Type: types.LinkTypeRecovery, Email: "user@example.com", RedirectTo: "https://myapp.com/reset-password", }) if err != nil { log.Fatal(err) } log.Printf("Action link: %s", linkResp.ActionLink) log.Printf("Send to user or log them in: %s", linkResp.EmailOTP) ``` -------------------------------- ### Configuration Composition Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Combines multiple configuration methods by chaining calls. ```go // Combine multiple configurations client := gotrue.New(projectRef, anonKey). WithCustomGoTrueURL("https://auth.company.com/auth/v1"). WithToken(serviceRoleToken). WithClient(http.Client{ Timeout: 30 * time.Second, }) // All configurations apply to this client users, err := client.AdminListUsers() ``` -------------------------------- ### Verify Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of verifying a signup token and handling the response, including error checking. ```go // Example: verifyResp, err := client.Verify(types.VerifyRequest{ Type: types.VerificationTypeSignup, Token: tokenFromEmail, RedirectTo: "https://myapp.com/auth-callback", }) if err != nil { log.Fatal(err) } // Check for errors in response if verifyResp.Error != "" { log.Fatalf("Verification failed: %s", verifyResp.ErrorDescription) } log.Printf("Verified, redirect to: %s", verifyResp.URL) log.Printf("Access token: %s", verifyResp.AccessToken) ``` -------------------------------- ### VerifyFactor Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/factor-endpoints.md Example of how to use the VerifyFactor method to complete MFA verification. ```go authedClient := client.WithToken(userAccessToken) // User provides 6-digit TOTP code from their authenticator app totpCode := "123456" verifyResp, err := authedClient.VerifyFactor(types.VerifyFactorRequest{ FactorID: enrolledFactorID, ChallengeID: challengeID, Code: totpCode, }) if err != nil { log.Fatal(err) } log.Printf("Factor verified! New access token: %s", verifyResp.AccessToken) log.Printf("Token expires at: %v", time.Unix(verifyResp.ExpiresAt, 0)) // Now use the new session for subsequent requests newAuthedClient := client.WithToken(verifyResp.AccessToken) user, _ := newAuthedClient.GetUser() log.Printf("Verified user: %s", user.Email) ``` -------------------------------- ### GetUser Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of how to use the GetUser function to retrieve user profile information. ```go authedClient := client.WithToken(accessToken) user, err := authedClient.GetUser() if err != nil { log.Fatal(err) } log.Printf("User Email: %s", user.Email) log.Printf("User ID: %s", user.ID) log.Printf("Last Sign In: %v", user.LastSignInAt) ``` -------------------------------- ### Example - Custom TLS Configuration Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Configures custom TLS settings for the HTTP client. ```go import ( "crypto/tls" "net/http" ) tlsConfig := &tls.Config{ InsecureSkipVerify: false, // Don't skip cert validation MinVersion: tls.VersionTLS12, } transport := &http.Transport{ TLSClientConfig: tlsConfig, } httpClient := http.Client{ Transport: transport, Timeout: 10 * time.Second, } secureClient := client.WithClient(httpClient) ``` -------------------------------- ### AdminDeleteUser Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of how to use the AdminDeleteUser function to delete a user. ```go adminClient := client.WithToken(adminToken) err := adminClient.AdminDeleteUser(types.AdminDeleteUserRequest{ UserID: userID, }) if err != nil { log.Fatal(err) } log.Println("User deleted") ``` -------------------------------- ### Example Usage of AdminDeleteSSOProvider Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md An example demonstrating how to use the AdminDeleteSSOProvider function to delete an SSO provider. ```go adminClient := client.WithToken(adminToken) deletedProvider, err := adminClient.AdminDeleteSSOProvider(types.AdminDeleteSSOProviderRequest{ ProviderID: providerID, }) if err != nil { log.Fatal(err) } log.Printf("Provider deleted: %s", deletedProvider.ID) ``` -------------------------------- ### User Struct Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Example of the User struct with JSON tags. ```go type User struct { ID uuid.UUID `json:"id"` Email string `json:"email"` // ... } ``` -------------------------------- ### UpdateUser Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of how to use the UpdateUser function to modify user profile details. ```go authedClient := client.WithToken(accessToken) updateResp, err := authedClient.UpdateUser(types.UpdateUserRequest{ Email: "newemail@example.com", Data: map[string]interface{}{ "first_name": "Jane", }, }) if err != nil { log.Fatal(err) } log.Printf("User updated: %s", updateResp.Email) log.Printf("Email change verification sent") ``` -------------------------------- ### BanDuration Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Example usage of BanDuration for setting no ban or a specific ban duration. ```go // No ban noBan := types.BanDurationNone() // Ban for 24 hours ban24h := types.BanDurationTime(24 * time.Hour) // Ban for 1 week banWeek := types.BanDurationTime(7 * 24 * time.Hour) ``` -------------------------------- ### Recover Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of how to use the Recover function to initiate the password recovery process. ```go err := client.Recover(types.RecoverRequest{ Email: "user@example.com", }) if err != nil { log.Fatal(err) } log.Println("Recovery email sent") ``` -------------------------------- ### Attribute Mapping Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example demonstrating custom attribute mapping for SAML attributes to GoTrue user fields. ```go provider, _ := adminClient.AdminCreateSSOProvider(types.AdminCreateSSOProviderRequest{ Type: "saml", MetadataURL: "https://okta.example.com/metadata", Domains: []string{"example.com"}, AttributeMapping: types.SAMLAttributeMapping{ Keys: map[string]types.SAMLAttribute{ "email": { Name: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", }, "full_name": { Name: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", }, }, }, }) ``` -------------------------------- ### Example - SAMLMetadata Usage Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example showing how to retrieve SAML metadata and save it to a file or serve it via an HTTP endpoint. ```go // Get SAML metadata metadata, err := client.SAMLMetadata() if err != nil { log.Fatal(err) } // Write to file for configuration err = ioutil.WriteFile("saml-metadata.xml", metadata, 0644) if err != nil { log.Fatal(err) } // Or serve via HTTP endpoint for dynamic configuration http.HandleFunc("/saml/metadata", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/xml") w.Write(metadata) }) ``` -------------------------------- ### Request Validation Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Examples demonstrating request validation for Token and Verify methods. ```go // Validates grant_type, required fields _, err := client.Token(req) // Validates email/phone, type, token _, err = client.Verify(req) ``` -------------------------------- ### Example - Disable Redirect Following Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Configures the HTTP client to not follow redirects. ```go // Some endpoints return redirects // To prevent automatic following c := http.Client{ Timeout: 10 * time.Second, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse // Don't follow }, } noRedirectClient := client.WithClient(c) // For endpoints like SAML ACS resp, err := noRedirectClient.SAMLACS(request) ``` -------------------------------- ### Example - Standard SSO Flow Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example demonstrating the standard SSO flow where the user is redirected through the SSO provider and back to the specified RedirectTo URL. ```go // Redirect user to SSO ssoResp, err := client.SSO(types.SSORequest{ Domain: "example.com", // or ProviderID: uuid RedirectTo: "https://myapp.com/auth-callback", }) if err != nil { log.Fatal(err) } // ssoResp.HTTPResponse contains the response (after following redirects) // User is redirected through the SSO provider and back to RedirectTo ``` -------------------------------- ### OTP Example: Send OTP to phone Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of sending an OTP to a user's phone number, with auto-user creation enabled. ```go // Send OTP to phone err = client.OTP(types.OTPRequest{ Phone: "+1234567890", CreateUser: true, }) if err != nil { log.Fatal(err) } ``` -------------------------------- ### OTP Example: Send magic link to email Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Example of sending a magic link to a user's email using the OTP function. ```go // Send magic link to email err := client.OTP(types.OTPRequest{ Email: "user@example.com", }) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Example - Disable Automatic Redirect Following Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example demonstrating how to configure the HTTP client to not follow redirects automatically, returning the immediate redirect response. ```go // Configure client to not follow redirects noRedirectClient := client.WithClient(http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, }) ssoResp, err := noRedirectClient.SSO(types.SSORequest{ Domain: "example.com", }) if err != nil { log.Fatal(err) } // ssoResp.HTTPResponse is the redirect response, not the final response ``` -------------------------------- ### Refreshing Access Token Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example of how to obtain a new access token using a refresh token before the old one expires and update the client with the new token. ```go // Get new token before expiration newTokenResp, err := client.RefreshToken(oldRefreshToken) newClient := client.WithToken(newTokenResp.AccessToken) ``` -------------------------------- ### Example - Custom Timeout Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Increases the HTTP client timeout to 30 seconds. ```go client := gotrue.New(projectRef, anonKey) // Increase timeout to 30 seconds slowClient := client.WithClient(http.Client{ Timeout: 30 * time.Second, }) // Requests using slowClient will wait up to 30 seconds user, err := slowClient.GetUser() ``` -------------------------------- ### AdminUpdateUser Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of how to use the AdminUpdateUser function to update user details, including banning a user. ```go adminClient := client.WithToken(adminToken) // Ban user for 24 hours updateResp, err := adminClient.AdminUpdateUser(types.AdminUpdateUserRequest{ UserID: userID, EmailConfirm: true, BanDuration: types.BanDurationTime(24 * time.Hour), }) if err != nil { log.Fatal(err) } log.Printf("User updated, banned until: %v", updateResp.BannedUntil) ``` -------------------------------- ### Example Error Handling for Network & Connection Errors Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Shows how to check for standard Go library errors like context.DeadlineExceeded or net.DNSError. ```go client := gotrue.New(projectRef, apiKey) client = client.WithClient(http.Client{ Timeout: 5 * time.Second, }) user, err := client.GetUser() if err != nil { if errors.Is(err, context.DeadlineExceeded) { log.Println("Request timed out") } else if _, ok := err.(net.DNSError); ok { log.Println("DNS resolution failed") } } ``` -------------------------------- ### Create SSO Provider in GoTrue Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example of creating a new SAML SSO provider using the admin client. ```go provider, _ := adminClient.AdminCreateSSOProvider(types.AdminCreateSSOProviderRequest{ Type: "saml", MetadataURL: "https://okta.example.com/metadata", Domains: []string{"example.com"}, }) ``` -------------------------------- ### AdminListUserFactors Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of how to use the AdminListUserFactors function to list a user's MFA factors and print their details. ```go adminClient := client.WithToken(adminToken) factorsResp, err := adminClient.AdminListUserFactors(types.AdminListUserFactorsRequest{ UserID: userID, }) if err != nil { log.Fatal(err) } for _, factor := range factorsResp.Factors { log.Printf("Factor %s: type=%s, status=%s, name=%s", factor.ID, factor.FactorType, factor.Status, factor.FriendlyName) } ``` -------------------------------- ### Production Setup Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Configuration best practices for a production environment, including using environment variables and setting up a reliable HTTP client. ```go import ( "net/http" "time" ) // Use environment variables projectRef := os.Getenv("SUPABASE_PROJECT_REF") anonKey := os.Getenv("SUPABASE_ANON_KEY") serviceRole := os.Getenv("SUPABASE_SERVICE_ROLE_KEY") // Create base client client := gotrue.New(projectRef, anonKey) // Configure for reliability httpClient := http.Client{ Timeout: 15 * time.Second, } reliableClient := client.WithClient(httpClient) // Create admin client for server operations adminClient := reliableClient.WithToken(serviceRole) ``` -------------------------------- ### Example - Web Server ACS Handler Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md An example of how a web server can handle SAML responses by forwarding them to GoTrue's ACS endpoint. ```go // In your web application http.HandleFunc("/auth/saml/acs", func(w http.ResponseWriter, r *http.Request) { // Parse the incoming SAML response err := r.ParseForm() if err != nil { http.Error(w, "Invalid request", 400) return } // Forward to GoTrue ACS samlResp, err := client.SAMLACS(r) if err != nil { http.Error(w, "SAML processing failed", 500) return } // Copy GoTrue's response to client for name, values := range samlResp.Header { for _, value := range values { w.Header().Add(name, value) } } w.WriteHeader(samlResp.StatusCode) io.Copy(w, samlResp.Body) }) ``` -------------------------------- ### Typical MFA Flow Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/factor-endpoints.md A step-by-step example demonstrating a typical Multi-Factor Authentication (MFA) flow, from login to factor verification. ```go // 1. User logs in with email/password tokenResp, _ := client.SignInWithEmailPassword("user@example.com", "password") authedClient := client.WithToken(tokenResp.AccessToken) // 2. Get user's factors factors, _ := authedClient.GetUser() // contains Factors field // 3. If factors exist and are enabled, prompt for MFA if len(factors.Factors) > 0 { // 4. Initiate challenge for first factor challenge, _ := authedClient.ChallengeFactor(types.ChallengeFactorRequest{ FactorID: factors.Factors[0].ID, }) // 5. Prompt user for TOTP code // totpCode := getUserInput("Enter your authenticator code") // 6. Verify the code mfaResp, _ := authedClient.VerifyFactor(types.VerifyFactorRequest{ FactorID: factors.Factors[0].ID, ChallengeID: challenge.ID, Code: totpCode, }) // 7. Use MFA-verified session finalAuthedClient := client.WithToken(mfaResp.AccessToken) user, _ := finalAuthedClient.GetUser() log.Printf("User fully authenticated: %s", user.Email) } ``` -------------------------------- ### Increasing Default HTTP Timeout Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example of increasing the default HTTP timeout. ```go slowClient := client.WithClient(http.Client{ Timeout: 30 * time.Second, }) ``` -------------------------------- ### AdminGetUserResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Get user response. ```go type AdminGetUserResponse struct { User } ``` -------------------------------- ### Environment Variables for Configuration Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example of environment variables used to configure the GoTrue client, including project reference, anonymous key, service role key, and an optional custom GoTrue URL. ```env SUPABASE_PROJECT_REF=your_project_ref SUPABASE_ANON_KEY=your_anon_key SUPABASE_SERVICE_ROLE_KEY=your_service_role_key GOTRUE_URL=https://auth.example.com/auth/v1 # Optional for custom deployments ``` -------------------------------- ### Example Error Handling Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/factor-endpoints.md Demonstrates how to handle common errors when verifying a TOTP factor. ```go verifyResp, err := authedClient.VerifyFactor(verifyReq) if err != nil { if strings.Contains(err.Error(), "invalid code") { log.Println("Invalid TOTP code, please try again") } else if strings.Contains(err.Error(), "expired") { log.Println("Challenge expired, please request a new one") } else { log.Fatal(err) } } ``` -------------------------------- ### ErrInvalidGenerateLinkRequest Example Usage Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Demonstrates incorrect usage (signup without password, recovery with data) and correct usage of AdminGenerateLink for signup and recovery. ```go // Signup without password _, err := adminClient.AdminGenerateLink(types.AdminGenerateLinkRequest{ Type: types.LinkTypeSignup, Email: "newuser@example.com", // Password missing }) // err: "generate link request is invalid - email and password must be provided if Type is signup" // Recovery with data (not allowed) _, err = adminClient.AdminGenerateLink(types.AdminGenerateLinkRequest{ Type: types.LinkTypeRecovery, Email: "user@example.com", Data: map[string]interface{}{ "role": "admin", }, }) // err: "generate link request is invalid - data must not be provided if Type is recovery" // Correct usage - signup linkResp, err := adminClient.AdminGenerateLink(types.AdminGenerateLinkRequest{ Type: types.LinkTypeSignup, Email: "newuser@example.com", Password: "initialPass123", Data: map[string]interface{}{ "company": "ACME", }, }) // Correct usage - recovery linkResp, err = adminClient.AdminGenerateLink(types.AdminGenerateLinkRequest{ Type: types.LinkTypeRecovery, Email: "user@example.com", }) ``` -------------------------------- ### User Struct with JSON Tags Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Example of a User struct demonstrating standard Go struct tags for JSON serialization. ```go type User struct { ID uuid.UUID `json:"id"` Email string `json:"email"` Phone string `json:"phone"` } ``` -------------------------------- ### OAuth Authorization (PKCE) Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Example of how to perform OAuth authorization using PKCE flow with the GoTrue client. ```go // Get authorization URL authResp, _ := client.Authorize(types.AuthorizeRequest{ Provider: types.ProviderGoogle, FlowType: types.FlowPKCE, Scopes: "openid email profile", }) // Store verifier and redirect user to authResp.AuthorizationURL storeVerifier(authResp.Verifier) // After user authorizes and is redirected back with code: code := getCodeFromCallback() verifier := getStoredVerifier() // Exchange code for token tokenResp, _ := client.Token(types.TokenRequest{ GrantType: "pkce", Code: code, CodeVerifier: verifier, }) ``` -------------------------------- ### Validation Before Request Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Example of performing client-side validation on request parameters before sending the request to the server. ```go // Validate request before sending if req.Email == "" && req.Phone == "" { return fmt.Errorf("either email or phone must be provided") } if req.GrantType != "password" && req.GrantType != "refresh_token" { return fmt.Errorf("invalid grant_type: %s", req.GrantType) } // Now send request resp, err := client.Token(req) ``` -------------------------------- ### ErrInvalidVerifyRequest Example Usage Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Demonstrates incorrect usage (missing token, missing identifier for VerifyForUser) and correct usage of Verify and VerifyForUser. ```go // Missing token _, err := client.Verify(types.VerifyRequest{ Type: types.VerificationTypeSignup, // Token missing RedirectTo: "https://example.com", }) // err: "verify request is invalid - ..." // VerifyForUser without email/phone _, err = client.VerifyForUser(types.VerifyForUserRequest{ Type: types.VerificationTypeSignup, Token: "abc123", RedirectTo: "https://example.com", // Email and Phone both missing }) // err: "verify request is invalid - ..." // Correct Verify verifyResp, err := client.Verify(types.VerifyRequest{ Type: types.VerificationTypeSignup, Token: tokenFromEmail, RedirectTo: "https://example.com/callback", }) // Correct VerifyForUser verifyResp, err = client.VerifyForUser(types.VerifyForUserRequest{ Type: types.VerificationTypeSignup, Token: tokenFromEmail, RedirectTo: "https://example.com/callback", Email: "user@example.com", }) ``` -------------------------------- ### Custom GoTrue Deployment Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Example of how to configure the client to use a custom GoTrue deployment URL. ```go customURL := os.Getenv("GOTRUE_URL") // Use custom deployment client := gotrue.New(projectRef, apiKey). WithCustomGoTrueURL(customURL) ``` -------------------------------- ### Example Error Handling for HTTP Status Codes Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Demonstrates checking for specific HTTP status codes within error messages returned by the client. ```go user, err := client.GetUser() if err != nil { errMsg := err.Error() // Check status code in error message if strings.Contains(errMsg, "401") { log.Println("User not authenticated, redirecting to login") } else if strings.Contains(errMsg, "404") { log.Println("User not found") } else if strings.Contains(errMsg, "429") { log.Println("Rate limited, please wait") } else { log.Printf("Unexpected error: %v", err) } return } ``` -------------------------------- ### Client Initialization with API Keys Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Demonstrates how to initialize the GoTrue client for client-side use with an anonymous key and for server-side use with a service role key. ```go // Client-side (safe) client := gotrue.New(projectRef, anonKey) // Server-side only adminClient := client.WithToken(serviceRoleToken) ``` -------------------------------- ### Increasing HTTP Client Timeout Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example of how to increase the default HTTP client timeout to 30 seconds for scenarios requiring longer request durations. ```go // Increase to 30 seconds customClient := client.WithClient(http.Client{ Timeout: 30 * time.Second, }) ``` -------------------------------- ### UnenrollFactor Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/factor-endpoints.md Example of how to use the UnenrollFactor method to remove an MFA factor. ```go authedClient := client.WithToken(userAccessToken) unenrollResp, err := authedClient.UnenrollFactor(types.UnenrollFactorRequest{ FactorID: enrolledFactorID, }) if err != nil { log.Fatal(err) } log.Printf("Factor removed: %s", unenrollResp.ID) log.Println("User's MFA is now disabled") ``` -------------------------------- ### AdminDeleteUserFactor Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of how to delete a user's enrolled factor using the AdminDeleteUserFactor endpoint. ```go adminClient := client.WithToken(adminToken) err := adminClient.AdminDeleteUserFactor(types.AdminDeleteUserFactorRequest{ UserID: userID, FactorID: factorID, }) if err != nil { log.Fatal(err) } log.Println("Factor deleted") ``` -------------------------------- ### New() Function Signature Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Creates a new GoTrue client with basic configuration. ```Go func New(projectReference string, apiKey string) Client ``` -------------------------------- ### AdminUpdateUserFactor Example Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Example of how to update a user's enrolled factor using the AdminUpdateUserFactor endpoint. ```go adminClient := client.WithToken(adminToken) factorResp, err := adminClient.AdminUpdateUserFactor(types.AdminUpdateUserFactorRequest{ UserID: userID, FactorID: factorID, FriendlyName: "My Security Key", }) if err != nil { log.Fatal(err) } log.Printf("Factor updated: %s", factorResp.FriendlyName) ``` -------------------------------- ### Signup Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Register a new user with email/phone and password. ```go func (c Client) Signup(req types.SignupRequest) (*types.SignupResponse, error) ``` ```go signupResp, err := client.Signup(types.SignupRequest{ Email: "newuser@example.com", Password: "securepassword123", Data: map[string]interface{}{ "first_name": "John", "last_name": "Doe", }, }) if err != nil { log.Fatal(err) } // If autoconfirm is off, user will need email verification // If autoconfirm is on, session will be populated if signupResp.AccessToken != "" { log.Printf("User signed up and confirmed: %s", signupResp.User.Email) } else { log.Printf("User created, verification email sent: %s", signupResp.User.Email) } ``` -------------------------------- ### WithClient() Signature Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Configures a custom HTTP client for all requests. ```go func (c Client) WithClient(httpClient http.Client) Client ``` -------------------------------- ### Admin User Creation Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Shows how to create a new user using the admin client, including setting an initial password and confirming the email. ```go // Create admin client adminClient := client.WithToken(serviceRoleToken) // Create user password := "initialPassword123" user, _ := adminClient.AdminCreateUser(types.AdminCreateUserRequest{ Email: "newuser@example.com", Password: &password, EmailConfirm: true, UserMetadata: map[string]interface{}{ "full_name": "John Doe", }, }) ``` -------------------------------- ### Default Base URL Construction Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Shows how the default base URL is constructed. ```go baseURL := fmt.Sprintf("https://%s.supabase.co/auth/v1", projectReference) ``` -------------------------------- ### SettingsResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Server settings response. ```go type SettingsResponse struct { DisableSignup bool Autoconfirm bool MailerAutoconfirm bool PhoneAutoconfirm bool SmsProvider string MFAEnabled bool External ExternalProviders } ``` -------------------------------- ### Default HTTP Client Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md The default HTTP client configuration. ```go http.Client{ Timeout: time.Second * 10, } ``` -------------------------------- ### AdminListUsers Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Get a list of all users. ```go func (c Client) AdminListUsers() (*types.AdminListUsersResponse, error) ``` ```go adminClient := client.WithToken(adminToken) usersResp, err := adminClient.AdminListUsers() if err != nil { log.Fatal(err) } for _, user := range usersResp.Users { log.Printf("User: %s <%s>", user.ID, user.Email) } ``` -------------------------------- ### AdminListSSOProviders Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Get all SAML SSO providers. Requires an admin token. ```go adminClient := client.WithToken(adminToken) providersResp, err := adminClient.AdminListSSOProviders() if err != nil { log.Fatal(err) } for _, provider := range providersResp.Providers { log.Printf("Provider %s created at %v", provider.ID, provider.CreatedAt) for _, domain := range provider.SSODomains { log.Printf(" Domain: %s", domain.Domain) } } ``` -------------------------------- ### AdminCreateSSOProviderResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md SSO provider creation response. ```go type AdminCreateSSOProviderResponse struct { SSOProvider } ``` -------------------------------- ### SignupResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Signup endpoint response. ```go type SignupResponse struct { User Session } ``` -------------------------------- ### ErrInvalidAdminUpdateFactorRequest Example Usage Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Demonstrates incorrect usage (no fields to update) and correct usage of AdminUpdateUserFactor. ```go // No fields to update _, err := adminClient.AdminUpdateUserFactor(types.AdminUpdateUserFactorRequest{ UserID: userID, FactorID: factorID, // FriendlyName is empty - nothing to update! }) // err: "admin update factor request is invalid - nothing to update" // Correct usage factorResp, err := adminClient.AdminUpdateUserFactor(types.AdminUpdateUserFactorRequest{ UserID: userID, FactorID: factorID, FriendlyName: "New Name", }) ``` -------------------------------- ### AdminCreateUserResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md User creation response. ```go type AdminCreateUserResponse struct { User } ``` -------------------------------- ### Get GoTrue Metadata Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Code snippet to retrieve GoTrue's SAML metadata. ```go metadata, _ := client.SAMLMetadata() // Save and configure in your SAML provider ``` -------------------------------- ### HTTP Status Errors Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Example of how GoTrue Go returns HTTP status errors using fmt.Errorf. ```go fmt.Errorf("response status code %d: %s", statusCode, responseBody) ``` -------------------------------- ### SignupRequest Structure Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Represents a user registration request. ```go type SignupRequest struct { Email string Phone string Password string Data map[string]interface{} SecurityEmbed } ``` -------------------------------- ### SSOResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md SSO initiation response. ```go type SSOResponse struct { URL string HTTPResponse *http.Response } ``` -------------------------------- ### GetSettings Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Retrieves publicly available GoTrue server settings. ```go func (c Client) GetSettings() (*types.SettingsResponse, error) ``` ```go settings, err := client.GetSettings() if err != nil { log.Fatal(err) } log.Printf("Sign up disabled: %v", settings.DisableSignup) log.Printf("GitHub auth enabled: %v", settings.External.GitHub) log.Printf("SMS provider: %s", settings.SmsProvider) ``` -------------------------------- ### AdminCreateSSOProvider Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Create a new SAML SSO provider. Requires an admin token. ```go adminClient := client.WithToken(adminToken) provider, err := adminClient.AdminCreateSSOProvider(types.AdminCreateSSOProviderRequest{ ResourceID: "okta_prod", Type: "saml", MetadataURL: "https://okta.example.com/metadata", Domains: []string{"example.com"}, }) if err != nil { log.Fatal(err) } log.Printf("Provider created: %s", provider.ID) ``` -------------------------------- ### WithCustomGoTrueURL() Function Signature Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Configures a custom GoTrue server endpoint. ```Go func (c Client) WithCustomGoTrueURL(url string) Client ``` -------------------------------- ### Disable Redirect Following Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/sso-saml-endpoints.md Example of how to configure the HTTP client to not follow redirects, useful for capturing the redirect response itself. ```go // If you need to capture the redirect instead of following it noRedirectClient := client.WithClient(http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, }) resp, err := noRedirectClient.SAMLACS(samlRequest) if err != nil { log.Fatal(err) } // resp.StatusCode will be 303 (redirect), not the final response redirectURL := resp.Header.Get("Location") ``` -------------------------------- ### Invite Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Invites a new user with an email. ```go func (c Client) Invite(req types.InviteRequest) (*types.InviteResponse, error) ``` ```go // Use service role token for invitations adminClient := client.WithToken(serviceRoleToken) inviteResp, err := adminClient.Invite(types.InviteRequest{ Email: "newuser@example.com", Data: map[string]interface{}{ "company": "ACME Corp", }, }) if err != nil { log.Fatal(err) } log.Printf("User invited: %s", inviteResp.Email) ``` -------------------------------- ### Disabling TLS Certificate Verification (Development Only) Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Example of how to disable TLS certificate verification for development purposes. This is insecure and should not be used in production. ```go // Development only - insecure! devConfig := &tls.Config{ InsecureSkipVerify: true, } // Don't use in production ``` -------------------------------- ### Basic Usage Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/README.md Demonstrates basic usage of the gotrue-go client, including client creation, user sign-in, and retrieving user information. ```go package main import ( "log" "github.com/supabase-community/gotrue-go" "github.com/supabase-community/gotrue-go/types" ) func main() { // Create client client := gotrue.New("your_project_ref", "your_anon_key") // Sign in tokenResp, err := client.SignInWithEmailPassword( "user@example.com", "password", ) if err != nil { log.Fatal(err) } // Create authenticated client authedClient := client.WithToken(tokenResp.AccessToken) // Get user user, err := authedClient.GetUser() if err != nil { log.Fatal(err) } log.Printf("Authenticated as: %s", user.Email) } ``` -------------------------------- ### AdminCreateUserRequest Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Admin user creation request. ```go type AdminCreateUserRequest struct { Aud string Role string Email string Phone string Password *string EmailConfirm bool PhoneConfirm bool UserMetadata map[string]interface{} AppMetadata map[string]interface{} BanDuration time.Duration } ``` -------------------------------- ### AdminCreateSSOProviderRequest Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md SAML SSO provider creation request structure. ```go type AdminCreateSSOProviderRequest struct { ResourceID string Type string MetadataURL string MetadataXML string Domains []string AttributeMapping SAMLAttributeMapping } ``` -------------------------------- ### SSORequest Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md Single Sign-On initiation request. ```go type SSORequest struct { ProviderID uuid.UUID Domain string RedirectTo string SkipHTTPRedirect bool SecurityEmbed } ``` -------------------------------- ### ErrInvalidProjectReference Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/errors.md Returned when creating a client with an invalid project reference. ```go var ErrInvalidProjectReference = errors.New("cannot create gotrue client: invalid project reference") ``` ```go // This will not error at creation time client := gotrue.New("", "key") // Will fail later on first request // But actual request will fail _, err := client.GetUser() // err: "cannot create gotrue client: invalid project reference" ``` ```go err := validateProjectRef(projectRef) if err != nil { log.Fatal("Invalid project reference") } client := gotrue.New(projectRef, apiKey) ``` -------------------------------- ### AdminCreateUser Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/admin-endpoints.md Create a new user with specified properties. ```go func (c Client) AdminCreateUser(req types.AdminCreateUserRequest) (*types.AdminCreateUserResponse, error) ``` ```go adminClient := client.WithToken(adminToken) password := "initialPassword123" user, err := adminClient.AdminCreateUser(types.AdminCreateUserRequest{ Email: "newuser@example.com", Password: &password, EmailConfirm: true, Role: "user", UserMetadata: map[string]interface{}{ "full_name": "John Doe", }, }) if err != nil { log.Fatal(err) } log.Printf("User created: %s with ID %s", user.Email, user.ID) ``` -------------------------------- ### WithToken() Function Signature Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/configuration.md Sets the bearer token for authenticated requests. ```Go func (c Client) WithToken(token string) Client ``` -------------------------------- ### AdminListSSOProvidersResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md List SSO providers response. ```go type AdminListSSOProvidersResponse struct { Providers []SSOProvider } ``` -------------------------------- ### SignInWithPhonePassword Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/api-reference.md Convenience method for signing in with phone and password. ```go func (c Client) SignInWithPhonePassword(phone, password string) (*types.TokenResponse, error) ``` ```go tokenResp, err := client.SignInWithPhonePassword("+1234567890", "password123") if err != nil { log.Fatal(err) } log.Printf("User authenticated: %s", tokenResp.User.Email) ``` -------------------------------- ### ChallengeFactorRequest Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md MFA challenge initiation request. ```go type ChallengeFactorRequest struct { FactorID uuid.UUID } ``` -------------------------------- ### AdminListUsersResponse Source: https://github.com/supabase-community/gotrue-go/blob/main/_autodocs/types.md List all users response. ```go type AdminListUsersResponse struct { Users []User } ```