### Install PropelAuth FastAPI Library Source: https://docs.propelauth.com/getting-started/quickstart-be Installs the necessary PropelAuth package for FastAPI applications via pip. ```bash pip install propelauth_fastapi ``` -------------------------------- ### Install PropelAuth Go SDK Source: https://docs.propelauth.com/reference/backend-apis/go Command to install the PropelAuth Go package via go get. ```bash go get github.com/propelauth/propelauth-go ``` -------------------------------- ### Initialize AuthProvider Source: https://docs.propelauth.com/getting-started/quickstart-fe Wraps the root application component with AuthProvider to manage authentication state and user information retrieval. ```javascript import { AuthProvider } from "@propelauth/react"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( , document.getElementById("root") ); ``` -------------------------------- ### Install FastMCP Source: https://docs.propelauth.com/mcp-authentication/examples/python Installs the FastMCP framework, a Python library used for creating MCP servers and handling authentication. ```bash pip install fastmcp ``` -------------------------------- ### Test API Authentication via cURL Source: https://docs.propelauth.com/getting-started/quickstart-be Demonstrates how to verify endpoint security by making unauthenticated and authenticated requests using cURL. ```bash # Test unauthenticated request curl -v localhost:3001/api/whoami # Test authenticated request curl -H "Authorization: Bearer " localhost:3001/api/whoami ``` -------------------------------- ### Start Next.js Development Server Source: https://docs.propelauth.com/getting-started/example-apps/react-flask Command to run the Next.js development server. This command compiles the application and makes it available for local testing. ```bash npm run dev ``` -------------------------------- ### Configure Environment Variables Source: https://docs.propelauth.com/getting-started/quickstart-fe Sets the authentication URL in an environment file to allow the application to communicate with the PropelAuth service. ```text REACT_APP_AUTH_URL=https://something.propelauthtest.com # If you are using Vite: # VITE_AUTH_URL=https://something.propelauthtest.com ``` -------------------------------- ### Install PropelAuth NuGet Package Source: https://docs.propelauth.com/getting-started/additional-framework-guides/dot-net-oauth-guide Installs the PropelAuth library into your .NET project using the dotnet CLI. ```bash dotnet add package PropelAuth ``` -------------------------------- ### Implement Authentication Actions Source: https://docs.propelauth.com/getting-started/quickstart-fe Utilizes PropelAuth hooks to provide login, signup, account management, and logout functionality within the UI. ```javascript import { withAuthInfo, useRedirectFunctions, useLogoutFunction } from '@propelauth/react' const YourApp = withAuthInfo((props) => { const logoutFunction = useLogoutFunction() const { redirectToLoginPage, redirectToSignupPage, redirectToAccountPage } = useRedirectFunctions() if (props.isLoggedIn) { return (

You are logged in as {props.user.email}

) } else { return (

You are not logged in

) } }) ``` -------------------------------- ### Initialize PropelAuth in Next.js Source: https://docs.propelauth.com/reference/fullstack-apis/nextjsapp/automatic-installation Runs the interactive setup wizard to configure PropelAuth within a Next.js project directory. ```bash propelauth setup ``` -------------------------------- ### Installing PropelAuth and Chalice for Python Backend Source: https://docs.propelauth.com/getting-started/example-apps/react-python-chalice This section details the installation process for the `propelauth-py` and `chalice` Python libraries using pip. It also mentions the necessity of configuring the AWS CLI for Chalice's deployment of resources within AWS. Finally, it shows the command to create a new Chalice project. ```bash pip install propelauth-py chalice aws configure chalice new-project example ``` -------------------------------- ### Basic Axum API Setup Source: https://docs.propelauth.com/getting-started/example-apps/react-rust-axum Sets up a basic Axum web server with a single '/api/whoami' route that returns a simple JSON response. This serves as a starting point before implementing authentication. ```rust #[tokio::main(flavor = "current_thread")] async fn main() { let app = Router::new() .route("/api/whoami", get(whoami)) let listener = tokio::net::TcpListener::bind("0.0.0.0:3001").await.unwrap(); axum::serve(listener, app).await.unwrap(); } async fn whoami() -> Json { let response = json!({ "Hello": "World" }); Json(response) } ``` -------------------------------- ### GET /api/whoami Source: https://docs.propelauth.com/getting-started/quickstart-be An example protected endpoint that retrieves the current user's information. Access is restricted to authenticated users only. ```APIDOC ## GET /api/whoami ### Description Returns the user ID of the currently authenticated user. If the request is not authenticated, it returns a 401 Unauthorized response. ### Method GET ### Endpoint /api/whoami ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token (JWT) provided by PropelAuth. ### Request Example ```bash curl -H "Authorization: Bearer " localhost:3001/api/whoami ``` ### Response #### Success Response (200) - **user_id** (string) - The unique identifier of the authenticated user. #### Response Example { "user_id": "4795fb88-0a87-4cf1-a328-8f3f9cf74497" } #### Error Response (401) - **detail** (string) - "Not authenticated" ``` -------------------------------- ### Install PropelAuth React Library Source: https://docs.propelauth.com/getting-started/example-apps/react-flask NPM command to install the @propelauth/react library, which provides hooks and components for managing user authentication state within a React application. ```bash npm install @propelauth/react ``` -------------------------------- ### Initialize PropelAuth in FastAPI Source: https://docs.propelauth.com/getting-started/quickstart-be Configures the PropelAuth library using the Auth URL and API Key retrieved from the dashboard. This initialization is required to verify incoming requests. ```python from propelauth_fastapi import init_auth auth = init_auth("YOUR_AUTH_URL", "YOUR_API_KEY") ``` -------------------------------- ### Install PropelAuth Package for .NET Source: https://docs.propelauth.com/guides-and-examples/guides/dot-net-oauth-guide This command installs the PropelAuth NuGet package into your .NET project, enabling you to use PropelAuth services. ```bash dotnet add package PropelAuth ``` -------------------------------- ### OAuth Integration Setup Source: https://docs.propelauth.com/sso/enterprise-sso/other-providers Steps to configure OAuth integration within PropelAuth, including generating Client ID and Secret, and setting up Redirect URIs. ```APIDOC ## OAuth Integration Setup ### Description Configure your OAuth integration in PropelAuth to enable user login via SAML or other identity providers. This involves generating credentials and specifying redirect URIs. ### Method N/A (Configuration Steps) ### Endpoint N/A (Configuration Steps) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Basic Chalice App Structure (`app.py`) Source: https://docs.propelauth.com/getting-started/example-apps/react-python-chalice This is a minimal Chalice application file (`app.py`) that sets up a basic API endpoint. It initializes a Chalice app instance and defines a route `/whoami` that returns a simple JSON response. This serves as a starting point for building backend APIs with Chalice. ```python from chalice import Chalice app = Chalice(app_name='example') @app.route('/whoami') def index(): return {'Hello': 'World'} ``` -------------------------------- ### Install PropelAuth CLI Source: https://docs.propelauth.com/reference/api/cli Installs the PropelAuth CLI globally on your system using npm. This is the prerequisite step for using CLI commands. ```bash npm i -g @propelauth/cli ``` -------------------------------- ### Install mcp-use dependency Source: https://docs.propelauth.com/mcp-authentication/examples/node Command to install the mcp-use framework via npm for building MCP servers. ```bash npm i mcp-use ``` -------------------------------- ### Login Method Property Examples Source: https://docs.propelauth.com/overview/user-management/user-properties Illustrates the structure of the `login_method` property in PropelAuth. It shows examples for social SSO with a provider and SAML SSO, including the `orgId` when applicable. ```json { login_method: "social_sso" provider: "GitHub" } ``` ```json { loginMethod: "saml_sso" provider: 'OneLogin' orgId: "abh1h13..." } ``` -------------------------------- ### Install PropelAuth Express Library Source: https://docs.propelauth.com/getting-started/example-apps/react-express Command to install the necessary PropelAuth package for Express backend integration. ```bash npm install @propelauth/express ``` -------------------------------- ### Install propelauth-py Library Source: https://docs.propelauth.com/getting-started/additional-framework-guides/streamlit-authentication Command to install the propelauth-py Python library using pip. ```bash pip install propelauth_py ``` -------------------------------- ### Installation Source: https://docs.propelauth.com/reference/backend-apis/fastapi Install the PropelAuth FastAPI library using pip. ```APIDOC ## Installation ### Description Install the propelauth_fastapi library using pip. ### Method pip ### Endpoint N/A ### Parameters None ### Request Example ```bash pip install propelauth_fastapi ``` ### Response None ``` -------------------------------- ### Install PropelAuth Python Library Source: https://docs.propelauth.com/migrations/supabase Command to install the necessary Python package for interacting with the PropelAuth API. ```bash pip install propelauth_py ``` -------------------------------- ### Install Dependencies for Migration Source: https://docs.propelauth.com/migrations/clerk Install the necessary Python libraries for data manipulation and API requests to facilitate the migration process. ```bash pip install requests pandas pip install propelauth_py ``` -------------------------------- ### Install dash-auth Library Source: https://docs.propelauth.com/getting-started/additional-framework-guides/dash-authentication Installs the dash-auth library, which is required for integrating authentication features into Dash applications. This command should be run in your project's environment. ```bash pip install dash_auth ``` -------------------------------- ### Install PropelAuth Node.js Library Source: https://docs.propelauth.com/reference/backend-apis/node Installs the PropelAuth Node.js library using npm. This is the first step to integrating PropelAuth into your Node.js project. ```bash npm install @propelauth/node ``` -------------------------------- ### Install boto3 for AWS SDK Source: https://docs.propelauth.com/migrations/cognito Installs the boto3 library, which is the AWS SDK for Python, used for interacting with AWS services like Cognito. ```bash pip install boto3 ``` -------------------------------- ### Configure Next.js Project Options Source: https://docs.propelauth.com/getting-started/example-apps/react-flask Example prompts and selections for configuring a new Next.js project with TypeScript and the Pages Router, excluding the App Router. ```bash ✔ What is your project named? `my-app` ✔ Would you like to use TypeScript? `Yes` ✔ Would you like to use App Router? (recommended) `No` ``` -------------------------------- ### Basic Express Server Setup Source: https://docs.propelauth.com/getting-started/example-apps/react-express Initializes an Express server with a simple '/api/whoami' route that returns 'Hello: World'. This serves as a baseline before implementing authentication. ```javascript const express = require('express') const app = express() const port = 3001 app.get('/api/whoami', (req, res) => { res.send({ Hello: 'World' }) }) app.listen(port, () => { console.log(`Example app listening on port ${port}`) }) ``` -------------------------------- ### Display User Information Source: https://docs.propelauth.com/getting-started/quickstart-fe Uses the withAuthInfo higher-order component to inject authentication status and user details into a React component. ```javascript import { withAuthInfo } from '@propelauth/react' const YourApp = withAuthInfo((props) => { if (props.isLoggedIn) { return

You are logged in as {props.user.email}

} else { return

You are not logged in

} }) export default YourApp ``` -------------------------------- ### Deploy Chalice Application Source: https://docs.propelauth.com/getting-started/example-apps/react-python-chalice Command to deploy the Chalice backend application to AWS. ```bash chalice deploy ``` -------------------------------- ### Install Go MCP SDK Source: https://docs.propelauth.com/mcp-authentication/examples/go Add the official Model Context Protocol SDK to your Go project dependencies. ```text require github.com/modelcontextprotocol/go-sdk ``` -------------------------------- ### Initialize PropelAuth Client and Create Magic Link Source: https://docs.propelauth.com/reference/backend-apis/go Initializes the PropelAuth client with authentication credentials and demonstrates how to create a magic link for user authentication. Requires the auth URL and API key. ```go client, err := propelauth.InitBaseAuth(authUrl, apiKey, nil) response, err := client.CreateMagicLink(models.CreateMagicLinkParams{ Email: "test@example.com", }) ``` -------------------------------- ### Configure HTTP Server Endpoints in Go Source: https://docs.propelauth.com/mcp-authentication/examples/go Sets up HTTP handlers for different routes including a main endpoint, a health check, and an OAuth protected resource metadata endpoint. It then starts the HTTP server. ```Go http.HandleFunc("/mcp", authenticatedHandler.ServeHTTP) // Health check endpoint. http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]string{ "status": "healthy", "time": time.Now().Format(time.RFC3339), }) }) // This endpoint provides OAuth configuration information to clients. metadata := &oauthex.ProtectedResourceMetadata{ Resource: mcpServerUrl + "/mcp", AuthorizationServers: []string{ propelauthAuthUrl + "/oauth/2.1", }, ScopesSupported: []string{"read:user_data"}, } http.Handle("/.well-known/oauth-protected-resource", auth.ProtectedResourceMetadataHandler(metadata)) // Start the HTTP server. log.Println("Authenticated MCP Server") log.Println("========================") log.Println("Server starting on", *httpAddr) log.Fatal(http.ListenAndServe(*httpAddr, nil)) } ``` -------------------------------- ### Chalice Deployment Output Source: https://docs.propelauth.com/getting-started/example-apps/react-python-chalice This example shows the typical output when deploying a Chalice application using the `chalice deploy` command. It indicates the creation of a deployment package, updates to IAM policies and Lambda functions, and the provisioning of a REST API. The output includes the Lambda ARN and the Rest API URL for the deployed application. ```bash $ chalice deploy Creating deployment package. Updating policy for IAM role: example-dev Updating lambda function: example-dev Updating rest API Resources deployed: - Lambda ARN: {ARN} - Rest API URL: https://{uniquestring}.execute-api.us-west-2.amazonaws.com/api/ ``` -------------------------------- ### UserInfo Endpoint Authorization Header Example Source: https://docs.propelauth.com/sso/enterprise-sso/other-providers Demonstrates how to pass an access token in the Authorization header for the UserInfo endpoint. This is crucial for retrieving user details from your authentication provider. ```http Authorization: Bearer {ACCESS_TOKEN} ``` -------------------------------- ### Protect API Endpoints with PropelAuth Source: https://docs.propelauth.com/getting-started/quickstart-be Uses the auth.require_user dependency to restrict access to specific FastAPI routes. Requests without a valid access token will receive a 401 Unauthorized response. ```python from fastapi import Depends from propelauth_fastapi import User @app.get("/api/whoami") async def root(current_user: User = Depends(auth.require_user)): return {"user_id": f"{current_user.user_id}"} ``` -------------------------------- ### POST /api/magic-link Source: https://docs.propelauth.com/reference/backend-apis/go Example of initializing the PropelAuth client and calling backend APIs to perform actions like creating a magic link. ```APIDOC ## POST /api/magic-link ### Description Initializes the PropelAuth client and triggers a magic link creation request. ### Method POST ### Request Body - **Email** (string) - Required - The email address to send the magic link to. ### Request Example { "Email": "test@example.com" } ### Response Example { "url": "https://auth.example.com/magic-link/..." } ``` -------------------------------- ### Setup PropelAuth AuthProvider in Next.js Source: https://docs.propelauth.com/getting-started/example-apps/react-flask Integrates the PropelAuth AuthProvider into the Next.js application's root component (_app.tsx). It requires the authentication URL from the PropelAuth dashboard to manage user sessions. ```typescript import type { AppProps } from 'next/app' import { AuthProvider } from '@propelauth/react' export default function App({ Component, pageProps }: AppProps) { return ( ) } ``` -------------------------------- ### Initialize PropelAuth and Call Backend APIs Source: https://docs.propelauth.com/reference/backend-apis/express Shows how to initialize the PropelAuth backend client using an API key and perform administrative actions such as creating a magic link. ```javascript const auth = initAuth({ authUrl: 'REPLACE_ME', apiKey: 'REPLACE_ME', }) const magicLink = await auth.createMagicLink({ email: 'user@customer.com', }) ``` -------------------------------- ### PropelAuth UserInfo JSON Object Structure Source: https://docs.propelauth.com/sso/enterprise-sso/other-providers An example JSON object representing user details, organization information, and roles provided by PropelAuth via the UserInfo endpoint. This structure is used for mapping attributes within your application. ```json { "can_create_orgs": false, "created_at": 1711127287, "email": "test@propelauth.com", "email_confirmed": true, "enabled": true, "first_name": "Anthony", "has_password": true, "last_active_at": 1712328977, "last_name": "Edwards", "locked": false, "metadata": null, "mfa_enabled": false, "org_member_info": { "org_id": "35905720-f22a-4f36-b082-7f35bb32463f", "org_metadata": {}, "org_name": "PropelAuth", "url_safe_org_name": "propelauth", "inherited_user_roles_plus_current_role": [ "Owner", "Admin", "Member" ], "user_permissions": [ "propelauth::can_invite", "propelauth::can_change_roles", "propelauth::can_remove_users", "propelauth::can_setup_saml", "propelauth::can_manage_api_keys" ], "user_role": "Owner" }, "picture_url": "https://img.propelauth.com/2a27d237-db8c-4f82-84fb-5824dfaedc87.png", "properties": { "favoriteSport": "Basketball" }, "sub": "0497bbe6-49c1-4bc7-9e9c-c75846722c73", "update_password_required": false, "user_id": "0497bbe6-49c1-4bc7-9e9c-c75846722c73" } ``` -------------------------------- ### Initialize Application with AuthWrapper Source: https://docs.propelauth.com/reference/frontend-apis/react/authProviderForTesting-guide Demonstrates how to replace the standard AuthProvider with the custom AuthWrapper in the root of a React application. ```javascript import AuthWrapper from './components/AuthWrapper'; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( , document.getElementById("root") ); ``` -------------------------------- ### Adding PropelAuth to Chalice `requirements.txt` Source: https://docs.propelauth.com/getting-started/example-apps/react-python-chalice This snippet shows how to add the `propelauth-py` library, specifically version `3.1.16`, to a Chalice project's `requirements.txt` file. This ensures that the necessary authentication library is installed when the Chalice application is deployed. ```text propelauth-py==3.1.16 ``` -------------------------------- ### Example PropelAuth User Object Structure Source: https://docs.propelauth.com/sso/enterprise-sso/cognito This JSON object represents the structure of a user profile in PropelAuth, including organization membership, roles, and permissions. It is used to guide the mapping of custom attributes when configuring Cognito OIDC providers. ```json { "can_create_orgs": false, "created_at": 1711127287, "email": "test@propelauth.com", "email_confirmed": true, "enabled": true, "first_name": "Anthony", "has_password": true, "last_active_at": 1712328977, "last_name": "Edwards", "locked": false, "metadata": null, "mfa_enabled": false, "org_id_to_org_info": { "35905720-f22a-4f36-b082-7f35bb32463f": { "org_id": "35905720-f22a-4f36-b082-7f35bb32463f", "org_name": "PropelAuth", "url_safe_org_name": "propelauth", "user_role": "Owner", "inherited_user_roles_plus_current_role": [ "Owner", "Admin", "Member" ], "org_metadata": {}, "user_permissions": [ "propelauth::can_invite", "propelauth::can_change_roles", "propelauth::can_remove_users", "propelauth::can_setup_saml", "propelauth::can_manage_api_keys" ] } }, "picture_url": "https://img.propelauth.com/2a27d237-db8c-4f82-84fb-5824dfaedc87.png", "properties": { "favoriteSport": "Basketball" }, "sub": "0497bbe6-49c1-4bc7-9e9c-c75846722c73", "update_password_required": false, "user_id": "0497bbe6-49c1-4bc7-9e9c-c75846722c73" } ``` -------------------------------- ### Initialize PropelAuth Client Source: https://docs.propelauth.com/reference/backend-apis/go Initializes the PropelAuth client using API keys and authentication URLs. Supports standard initialization or manual metadata input for serverless environments. ```go import ( "os" "fmt" propelauth "github.com/propelauth/propelauth-go/pkg" models "github.com/propelauth/propelauth-go/pkg/models" ) func main() { apiKey := os.Getenv("PROPELAUTH_API_KEY") authUrl := os.Getenv("PROPELAUTH_AUTH_URL") client, err := propelauth.InitBaseAuth(authUrl, apiKey, nil) if err != nil { panic(err) } } ``` ```go client, err := propelauth.InitBaseAuth(authUrl, apiKey, &propelauth.TokenVerificationMetadataInput{ VerifierKey: os.Getenv("PROPELAUTH_VERIFIER_KEY"), Issuer: os.Getenv("PROPELAUTH_ISSUER"), }) ``` -------------------------------- ### Authenticate Backend API Requests Source: https://docs.propelauth.com/reference/api/getting-started All requests to the PropelAuth Backend API must include an Authorization header containing a valid API key as a Bearer token. This key is generated via the PropelAuth dashboard for specific environments. ```HTTP { "Authorization": "Bearer {YOUR_API_KEY}" } ``` -------------------------------- ### Redirect to Setup SAML Page (JavaScript) Source: https://docs.propelauth.com/reference/fullstack-apis/nextjsapp/client-component-hooks Redirects the user to the organization SAML setup page for a given organization ID. If no ID is provided, an organization is chosen automatically. Supports `redirectBackToUrl`. ```javascript "use client"; import {useRedirectFunctions} from "@propelauth/nextjs/client" const { redirectToSetupSAMLPage } = useRedirectFunctions() redirectToSetupSAMLPage("org_789", { redirectBackToUrl: "/settings/saml", }) ``` -------------------------------- ### Iterate Through User Organizations (JavaScript) Source: https://docs.propelauth.com/reference/frontend-apis/js This example shows how to fetch all organizations a user is a member of using the `orgHelper.getOrgs()` method from the `AuthenticationInfo` object. It then iterates through each organization to display the user's role within that organization. This requires the `@propelauth/javascript` SDK to be installed and configured. ```javascript import {createClient} from "@propelauth/javascript" const authClient = createClient({...}) const authInfo = await authClient.getAuthenticationInfoOrNull() if (!authInfo) { console.log("User is not logged in") return; } const orgs = authInfo.orgHelper.getOrgs() for (const org of orgs) { console.log("User is a", org.userAssignedRole, "in", org.orgName) } ``` -------------------------------- ### Fetch Organization Information (React/Next.js) Source: https://docs.propelauth.com/getting-started/example-apps/react-flask This React component fetches organization details using the `useEffect` hook and the `useRouter` hook to get the organization ID from the URL. It makes an authenticated fetch request to a backend API. Dependencies include `@propelauth/react` and `next/router`. ```typescript import { withRequiredAuthInfo, WithLoggedInAuthInfoProps } from '@propelauth/react'; import { useRouter } from 'next/router'; import { useEffect, useState } from "react"; function fetchOrgInfo(orgId: String, accessToken: String) { return fetch(`/api/org/${orgId}`, { headers: { "Content-Type": "application/json", "Authorization": `Bearer ${accessToken}` } }).then(response => { if (response.ok) { return response.json() } else { return { status: response.status } } }) } function OrgInfo({ accessToken }: WithLoggedInAuthInfoProps) { const router = useRouter(); const orgId = router.query.orgId; const [response, setResponse] = useState(null) useEffect(() => { fetchOrgInfo(orgId? orgId.toString() : "", accessToken).then(setResponse) }, [orgId, accessToken]) return

{response ? JSON.stringify(response) : "Loading..."}

} export default withRequiredAuthInfo(OrgInfo); ``` -------------------------------- ### Configure PropelAuth Authentication in ASP.NET Core Source: https://docs.propelauth.com/guides-and-examples/guides/dot-net-oauth-guide This setup configures the authentication pipeline by combining JWT Bearer authentication for API requests and OAuth2 for user login. It includes custom event handlers to manage token extraction from cookies and secure storage of access and refresh tokens. ```csharp builder.Services.AddAuthentication(options => { options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = "PropelAuth"; }).AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateAudience = false, ValidAlgorithms = new List() { "RS256" }, ValidIssuer = AUTH_URL, IssuerSigningKey = new RsaSecurityKey(rsa), ValidateLifetime = true, ClockSkew = TimeSpan.Zero }; options.Events = new JwtBearerEvents { OnMessageReceived = context => { string? token = context.Request.Cookies["__pa_at"]; if (string.IsNullOrEmpty(token)) { return Task.CompletedTask; } context.Token = token; return Task.CompletedTask; } }; }).AddOAuth("PropelAuth", options => { options.AuthorizationEndpoint = AUTH_URL + "/propelauth/oauth/authorize"; options.CallbackPath = "/auth/callback"; options.ClientId = CLIENT_ID; options.ClientSecret = CLIENT_SECRET; options.TokenEndpoint = AUTH_URL + "/propelauth/oauth/token"; options.UserInformationEndpoint = AUTH_URL + "/propelauth/oauth/userinfo"; options.SaveTokens = true; options.Events = new OAuthEvents { OnCreatingTicket = context => { if (!string.IsNullOrEmpty(context.AccessToken)) { context.HttpContext.Response.Cookies.Append("__pa_at", context.AccessToken, new CookieOptions() { HttpOnly = true, SameSite = SameSiteMode.Lax, IsEssential = true, Secure = true, MaxAge = TimeSpan.FromMinutes(25), }); } if (!string.IsNullOrEmpty(context.RefreshToken)) { context.HttpContext.Response.Cookies.Append("__pa_rt", context.RefreshToken, new CookieOptions() { HttpOnly = true, SameSite = SameSiteMode.Lax, IsEssential = true, Secure = true, MaxAge = TimeSpan.FromDays(14), }); } return Task.CompletedTask; } }; }).AddCookie(); ``` -------------------------------- ### Initialize PropelAuth Client with CDN Source: https://docs.propelauth.com/reference/frontend-apis/js Illustrates how to create a PropelAuth client when using the CDN. A global `PropelAuth` object is available, from which `createClient` can be called. ```javascript ``` -------------------------------- ### Get and Use Auth Info with useAuthInfo Hook (React) Source: https://docs.propelauth.com/reference/frontend-apis/react This example shows how to use the useAuthInfo hook to access authentication state and user data within a React component. It handles loading states, checks login status, and displays user email or a message indicating the user is not logged in. ```javascript const WelcomeMessage = () => { const authInfo = useAuthInfo() if (authInfo.loading) { return
Loading...
} else if (authInfo.isLoggedIn) { return
Welcome, {authInfo.user.email}!
} else { return
You aren't logged in
} } ```