### Install Project Dependencies Source: https://github.com/toolbeam/openauth/blob/master/examples/README.md Installs all necessary workspace packages for the project. This command should be run from the project root. ```shell $ bun install ``` -------------------------------- ### Start Development Server Source: https://github.com/toolbeam/openauth/blob/master/examples/quickstart/standalone/README.md Commands to run the Next.js development server. These commands are executed in the project's root directory. Ensure you have the appropriate package manager installed (npm, yarn, pnpm, or bun). The server typically starts at http://localhost:3000. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Run Astro Client Source: https://github.com/toolbeam/openauth/blob/master/examples/README.md Navigates into the astro client directory and starts the development server using Bun. This allows you to test the authentication flow. ```shell $ cd client/astro $ bun dev ``` -------------------------------- ### Start Development Server Source: https://github.com/toolbeam/openauth/blob/master/examples/quickstart/sst/README.md Commands to run the Next.js development server. These commands are executed in the project's root directory. Ensure you have the appropriate package manager installed (npm, yarn, pnpm, or bun). The server typically starts at http://localhost:3000. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Create Next.js Project and Start Dev Server Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/standalone.mdx Commands to create a new Next.js application using bun, navigate into the project directory, and start the development server. It prompts for TypeScript and skips ESLint. ```bash bun create next-app oa-nextjs cd oa-nextjs bun dev ``` -------------------------------- ### Add OpenAuth Server Start Script to package.json Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/standalone.mdx Adds a script to package.json to run the OpenAuth server using bun, specifying the port and enabling hot-reloading for development. ```json "dev:auth": "PORT=3001 bun run --hot auth/index.ts" ``` -------------------------------- ### Start OpenAuth Server Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/standalone.mdx Command to start the OpenAuth server in a separate terminal using bun, enabling hot-reloading. Assumes the server is configured to run on port 3001. ```bash bun dev:auth ``` -------------------------------- ### Run OpenAuth Bun Issuer Source: https://github.com/toolbeam/openauth/blob/master/examples/README.md Starts the OpenAuth issuer server using Bun with hot reloading. This command brings up the server on port 3000. ```shell $ bun run --hot ./issuer/bun/issuer.ts ``` -------------------------------- ### npm Project Commands Source: https://github.com/toolbeam/openauth/blob/master/www/README.md A collection of essential npm commands for managing an Astro project. These commands cover dependency installation, starting the development server, building for production, and previewing the build. ```APIDOC npm install - Installs project dependencies. npm run dev - Starts the local development server, typically at http://localhost:4321. npm run build - Builds the production-ready static site into the ./dist/ directory. npm run preview - Previews the production build locally before deploying. npm run astro ... - Executes Astro CLI commands, such as 'astro add' or 'astro check'. npm run astro -- --help - Displays help information for the Astro CLI. ``` -------------------------------- ### DiscordProvider Initialization Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/discord.mdx Example demonstrating how to initialize the DiscordProvider with client ID and client secret. This setup is used for authenticating with Discord via OAuth2. ```TypeScript import { DiscordProvider } from "@openauthjs/openauth/provider/discord" export default issuer({ providers: { discord: DiscordProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### Start OpenAuth Issuer Server Source: https://github.com/toolbeam/openauth/blob/master/examples/client/react/README.md Starts the OpenAuth issuer server, which is required for the authentication flow. This server is typically run from the examples directory. ```bash bun run --hot issuer/bun/issuer.ts ``` -------------------------------- ### Install OpenAuth Dependencies Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/sst.mdx Installs the necessary OpenAuth libraries, Valibot for schema validation, and Hono for building the serverless API. ```bash npm install @openauthjs/openauth valibot hono ``` -------------------------------- ### Start Development Server Source: https://github.com/toolbeam/openauth/blob/master/examples/client/nextjs/README.md Commands to start the development server for the OpenAuth Next.js project. These commands are compatible with npm, yarn, pnpm, and bun package managers. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Example sendCode Implementation Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/code.mdx An example of how to implement the `sendCode` callback function, demonstrating how to send the generated code to the user based on claims. ```ts sendCode: async (claims, code) => { // Send the code through the email or phone number based on the claims } ``` -------------------------------- ### Build OpenAuth Package Source: https://github.com/toolbeam/openauth/blob/master/examples/README.md Navigates into the openauth package directory and builds the package using Bun. This is a prerequisite for running the issuer. ```shell $ cd packages/openauth $ bun run build ``` -------------------------------- ### Start JWT API Server with Bun Source: https://github.com/toolbeam/openauth/blob/master/examples/client/jwt-api/README.md Command to start the JWT API server using Bun. This command enables hot-reloading for development. The API is accessible at `http://localhost:3001/`. ```bash bun run --hot index.ts ``` -------------------------------- ### JumpCloudProvider Initialization Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/jumpcloud.mdx Example of initializing the JumpCloudProvider with essential configuration parameters like clientID and clientSecret. ```ts import { JumpCloudProvider } from "@openauthjs/openauth/provider/jumpcloud" export default issuer({ providers: { jumpcloud: JumpCloudProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### XProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/x.mdx Demonstrates how to initialize and use the XProvider with client credentials for authentication. ```TypeScript import { XProvider } from "@openauthjs/openauth/provider/x" export default issuer({ providers: { x: XProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### Install Workspace Packages and Build OpenAuth Source: https://github.com/toolbeam/openauth/blob/master/examples/client/react/README.md Installs all necessary workspace packages in the project root and then builds the OpenAuth package. This is a prerequisite for running the application. ```bash bun install cd packages/openauth bun run build ``` -------------------------------- ### KeycloakProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/keycloak.mdx Example of how to use the KeycloakProvider to authenticate with a Keycloak server. It requires configuration parameters such as baseUrl, realm, clientID, and clientSecret. ```ts import { KeycloakProvider } from "@openauthjs/openauth/provider/keycloak" export default issuer({ providers: { keycloak: KeycloakProvider({ baseUrl: "https://your-keycloak-domain", realm: "your-realm", clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### Start SST Development Mode Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/sst.mdx Starts the SST development server, which concurrently runs the Next.js application and the OpenAuth server. It provides URLs for accessing both services. ```bash npx sst dev ``` -------------------------------- ### TwitchProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/twitch.mdx Example demonstrating how to import and use the `TwitchProvider` within an issuer configuration, providing client ID and client secret. ```typescript import { TwitchProvider } from "@openauthjs/openauth/provider/twitch" export default issuer({ providers: { twitch: TwitchProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### OidcProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/oidc.mdx Demonstrates how to initialize the OidcProvider with essential configuration parameters like clientId and issuer. ```ts import { OidcProvider } from "@openauthjs/openauth/provider/oidc" export default issuer({ providers: { oauth2: OidcProvider({ clientId: "1234567890", issuer: "https://auth.myserver.com" }) } }) ``` -------------------------------- ### Create and Navigate Next.js App Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/sst.mdx Initializes a new Next.js project using create-next-app and changes the directory into the newly created project. Assumes TypeScript and no ESLint are selected during setup. ```bash npx create-next-app@latest oa-nextjs cd oa-nextjs ``` -------------------------------- ### SlackConfig query Example (TypeScript) Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/slack.mdx Example of how to set additional query parameters for Slack authentication requests. These parameters are appended to the authorization endpoint URL. ```ts { query: { access_type: "offline", prompt: "consent" } } ``` -------------------------------- ### GithubProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/github.mdx Demonstrates how to initialize and use the GithubProvider for authentication with GitHub. It requires client ID and client secret for configuration. ```ts import { GithubProvider } from "@openauthjs/openauth/provider/github" export default issuer({ providers: { github: GithubProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### Create Microsoft OAuth2 Provider Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/microsoft.mdx Demonstrates how to set up the Microsoft OAuth2 provider for authentication. This configuration requires tenant, clientID, and clientSecret. ```ts import { MicrosoftProvider } from "@openauthjs/openauth/provider/microsoft" export default issuer({ providers: { microsoft: MicrosoftProvider({ tenant: "1234567890", clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### PasswordProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/password.mdx Demonstrates how to configure the `PasswordProvider` with `PasswordUI`, including custom copy and a `sendCode` callback. ```ts import { PasswordUI } from "@openauthjs/openauth/ui/password" import { PasswordProvider } from "@openauthjs/openauth/provider/password" export default issuer({ providers: { password: PasswordProvider( PasswordUI({ copy: { error_email_taken: "This email is already taken." }, sendCode: (email, code) => console.log(email, code) }) ) }, // ... }) ``` -------------------------------- ### Start React SPA Source: https://github.com/toolbeam/openauth/blob/master/examples/client/react/README.md Initiates the React Single Page Application development server. This command is used to run the client-side application locally. ```bash bun run dev ``` -------------------------------- ### Example CognitoConfig Usage Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/cognito.mdx Illustrates how to set up the CognitoConfig object with sample values for client ID, domain, region, and scopes. ```ts const cognitoConfig = { clientID: "your-cognito-client-id", clientSecret: "your-cognito-client-secret", domain: "your-cognito-domain.auth.your-region.amazoncognito.com", region: "your-region", scopes: ["openid", "profile", "email"], pkce: true }; ``` -------------------------------- ### Configure Issuer with Predefined Theme Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/issuer.mdx Demonstrates how to initialize the issuer function using a predefined theme object from the library. This is a basic setup for the issuer's UI. ```ts import { THEME_SST } from "@openauthjs/openauth/ui/theme" issuer({ theme: THEME_SST // ... }) ``` -------------------------------- ### OpenAuth Server Deployment Source: https://github.com/toolbeam/openauth/blob/master/README.md Examples for exporting the Hono application for deployment on different serverless and Node.js environments. Ensure the Hono app is correctly configured before exporting. ```typescript // Bun export default app // Cloudflare export default app // Lambda import { handle } from "hono/aws-lambda" export const handler = handle(app) // Node.js import { serve } from "@hono/node-server" serve(app) ``` -------------------------------- ### SlackProvider Usage Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/slack.mdx Demonstrates how to configure and use the SlackProvider for authentication with Slack, including essential parameters like team ID, client ID, client secret, and scopes. ```ts import { SlackProvider } from "@openauthjs/openauth/provider/slack" export default issuer({ providers: { slack: SlackProvider({ team: "T1234567890", clientID: "1234567890", clientSecret: "0987654321", scopes: ["openid", "email", "profile"] }) } }) ``` -------------------------------- ### Deploy OpenAuth Server Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/issuer.mdx Provides deployment examples for the OpenAuth server, which is built on Hono. This snippet demonstrates how to serve the Hono app in various environments including Node.js, AWS Lambda, and Bun/Workers. ```ts import { serve } from "@hono/node-server" serve(app) ``` ```ts import { handle } from "hono/aws-lambda" export const handler = handle(app) ``` ```ts export default app ``` ```ts export default app ``` -------------------------------- ### OpenAuth Server Configuration (TypeScript) Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/standalone.mdx TypeScript code defining the OpenAuth issuer with a code-based UI provider, memory storage, and a custom success handler to retrieve user IDs from a database. ```ts import { issuer } from "@openauthjs/openauth" import { CodeUI } from "@openauthjs/openauth/ui/code" import { CodeProvider } from "@openauthjs/openauth/provider/code" import { MemoryStorage } from "@openauthjs/openauth/storage/memory" import { subjects } from "./subjects" async function getUser(email: string) { // Get user from database and return user ID return "123" } export default issuer({ subjects, storage: MemoryStorage(), providers: { code: CodeProvider( CodeUI({ sendCode: async (email, code) => { console.log(email, code) }, }), ), }, success: async (ctx, value) => { if (value.provider === "code") { return ctx.subject("user", { id: await getUser(value.claims.email) }) } throw new Error("Invalid provider") }, }) ``` -------------------------------- ### Implement Success Callback Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/index.mdx Provides an example of the `success` callback, which is executed upon successful authentication. It handles different provider payloads, looks up or creates users, and returns a subject object using `ctx.subject()`, ensuring type safety. ```ts const app = issuer({ providers: { ... }, subjects, async success(ctx, value) { let userID if (value.provider === "password") { console.log(value.email) userID = ... // lookup user or create them } if (value.provider === "github") { console.log(value.tokenset.access) userID = ... // lookup user or create them } return ctx.subject("user", { userID, 'a workspace id' }) } }) ``` -------------------------------- ### Create Starlight Astro Project Source: https://github.com/toolbeam/openauth/blob/master/www/README.md Command to initialize a new Astro project using the Starlight template. This sets up the basic structure and dependencies for a documentation site. ```bash npm create astro@latest -- --template starlight ``` -------------------------------- ### Starlight Project Structure Source: https://github.com/toolbeam/openauth/blob/master/www/README.md Illustrates the typical directory and file structure of an Astro project initialized with Starlight. It highlights key directories like `public/` for static assets and `src/content/docs/` for documentation files. ```bash . ├── public/ ├── src/ │ ├── assets/ │ ├── content/ │ │ ├── docs/ │ │ └── config.ts │ └── env.d.ts ├── astro.config.mjs ├── package.json └── tsconfig.json ``` -------------------------------- ### Configure OAuth2 Provider Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/oauth2.mdx Example of configuring an OAuth 2.0 provider with client credentials and authorization/token endpoints. This setup is used to integrate external authentication services. ```ts import { Oauth2Provider } from "@openauthjs/openauth/provider/oauth2" export default issuer({ providers: { oauth2: Oauth2Provider({ clientID: "1234567890", clientSecret: "0987654321", endpoint: { authorization: "https://auth.myserver.com/authorize", token: "https://auth.myserver.com/token" } }) } }) ``` -------------------------------- ### SlackConfig clientID Example (TypeScript) Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/slack.mdx Example of how to set the clientID for Slack configuration. The clientID is a string used to identify your application. ```ts { clientID: "my-client" } ``` -------------------------------- ### SlackConfig clientSecret Example (TypeScript) Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/slack.mdx Example of how to set the clientSecret for Slack configuration. The clientSecret is a sensitive string used for app authentication. ```ts { clientSecret: "0987654321" } ``` -------------------------------- ### Initialize SpotifyProvider Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/spotify.mdx Demonstrates how to initialize the SpotifyProvider with client credentials for authentication. ```ts import { SpotifyProvider } from "@openauthjs/openauth/provider/spotify" export default issuer({ providers: { spotify: SpotifyProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### Initialize SST Project Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/sst.mdx Initializes the Serverless Stack (SST) framework in the current project. It prompts the user for configuration choices, typically defaulting to AWS as the cloud provider. ```bash npx sst@latest init ``` -------------------------------- ### Start JWT API Server Source: https://github.com/toolbeam/openauth/blob/master/examples/client/react/README.md Starts an optional JWT API server, which can be used to obtain user subjects. This server is useful for scenarios requiring JWT validation or processing. ```bash bun run --hot client/jwt-api/index.ts ``` -------------------------------- ### TypeScript Password Validation Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/ui/password.mdx An example implementation of a password validation callback function. This function checks if the provided password meets a minimum length requirement of 8 characters. It returns an error message string if the password is too short, otherwise returns undefined. ```typescript { validatePassword: (password) => { return password.length < 8 ? "Password must be at least 8 characters" : undefined } } ``` -------------------------------- ### SpotifyProvider Constructor and Configuration Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/spotify.mdx Details the SpotifyProvider constructor and its configuration options, including client ID, client secret, PKCE usage, custom query parameters, and requested scopes. ```APIDOC SpotifyProvider(config) - Creates a Spotify OAuth2 provider. - Parameters: - config: SpotifyConfig - clientID: string - The client ID to identify your app. - Example: ```ts { clientID: "my-client" } ``` - clientSecret: string - The private key used to authenticate your app. Keep this secret. - Example: ```ts { clientSecret: "0987654321" } ``` - pkce?: boolean - Whether to use PKCE (Proof Key for Code Exchange) for the authorization code flow. Defaults to false. Required by some providers like x.com. - query?: Record - Any additional parameters to pass to the authorization endpoint. - Example: ```ts { query: { access_type: "offline", prompt: "consent" } } ``` - scopes: string[] - A list of OAuth scopes to request for user permissions. - Example: ```ts { scopes: ["email", "profile"] } ``` - Returns: Provider - Example Usage: ```ts SpotifyProvider({ clientID: "1234567890", clientSecret: "0987654321" }) ``` ``` -------------------------------- ### Facebook OAuth2 Provider Usage Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/facebook.mdx Example demonstrating how to configure and use the FacebookProvider for OAuth2 authentication. Requires clientID and clientSecret. ```ts import { FacebookProvider } from "@openauthjs/openauth/provider/facebook" export default issuer({ providers: { facebook: FacebookProvider({ clientID: "1234567890", clientSecret: "0987654321" }) } }) ``` -------------------------------- ### XProvider API Documentation Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/x.mdx Documentation for the XProvider constructor and its configuration options. ```APIDOC XProvider(config) - Creates a X.com OAuth2 provider. - Parameters: - config (XProviderConfig): The configuration object for the provider. - clientID (string): The client ID to identify your application. - clientSecret (string): The client secret, a private key for app authentication. Keep this secret. - pkce? (boolean): Whether to use PKCE (Proof Key for Code Exchange). Defaults to false. Required by some providers like x.com. - query? (Record): Additional parameters to pass to the authorization endpoint. - scopes (string[]): An array of OAuth scopes to request. - Returns: Provider Example Usage: ```ts XProvider({ clientID: "1234567890", clientSecret: "0987654321" }) ``` XProviderConfig Parameters: - clientID (string): The client ID. This is just a string to identify your app. Example: ```ts { clientID: "my-client" } ``` - clientSecret (string): The client secret. This is a private key that's used to authenticate your app. It should be kept secret. Example: ```ts { clientSecret: "0987654321" } ``` - pkce? (boolean): Whether to use PKCE (Proof Key for Code Exchange) for the authorization code flow. Some providers like x.com require this. Default: false - query? (Record): Any additional parameters that you want to pass to the authorization endpoint. Example: ```ts { query: { access_type: "offline", prompt: "consent" } } ``` - scopes (string[]): A list of OAuth scopes that you want to request. Example: ```ts { scopes: ["email", "profile"] } ``` ``` -------------------------------- ### Initialize OpenAuth issuer with basic configuration Source: https://github.com/toolbeam/openauth/blob/master/README.md Demonstrates the basic structure for initializing the OpenAuth `issuer` function. It requires configuration for providers, storage, subjects, and a success callback. ```typescript const app = issuer({ providers: { ... }, storage, subjects, success: async (ctx, value) => { ... } }) ``` -------------------------------- ### JumpCloudProvider API Documentation Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/jumpcloud.mdx Documentation for the JumpCloudProvider function, its configuration options, and parameters. ```APIDOC JumpCloudProvider(config) - Creates a JumpCloud OAuth2 provider. - Parameters: - config: JumpCloudConfig - The configuration object for the provider. - clientID: string - The client ID for your JumpCloud application. - clientSecret: string - The client secret for your JumpCloud application. Keep this secret. - pkce?: boolean - Whether to use PKCE (Proof Key for Code Exchange). Defaults to false. Required by some providers. - query?: Record - Additional query parameters to include in the authorization request. - scopes: string[] - An array of OAuth scopes to request from JumpCloud. - Returns: Provider - An instance of the JumpCloud provider. Example Usage: JumpCloudProvider({ clientID: "your-client-id", clientSecret: "your-client-secret", scopes: ["email", "profile"] }) ``` -------------------------------- ### Create Microsoft OIDC Provider Example Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/microsoft.mdx Demonstrates how to set up the Microsoft OIDC provider, which is useful for verifying user email addresses. This configuration requires clientID. ```ts import { MicrosoftOidcProvider } from "@openauthjs/openauth/provider/microsoft" export default issuer({ providers: { microsoft: MicrosoftOidcProvider({ clientID: "1234567890" }) } }) ``` -------------------------------- ### Configuring DynamoDB Storage Adapter Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/issuer.mdx Example of integrating a DynamoDB storage adapter with the OpenAuth issuer. It shows importing the DynamoStorage and assigning it to the storage configuration. ```ts import { DynamoStorage } from "@openauthjs/openauth/storage/dynamo" issuer({ storage: DynamoStorage() // ... }) ``` -------------------------------- ### Facebook OIDC Provider Usage Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/facebook.mdx Example demonstrating how to configure and use the FacebookOidcProvider for OpenID Connect (OIDC) authentication. Primarily used for verifying user email addresses. ```ts import { FacebookOidcProvider } from "@openauthjs/openauth/provider/facebook" export default issuer({ providers: { facebook: FacebookOidcProvider({ clientID: "1234567890" }) } }) ``` -------------------------------- ### GithubProvider API Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/github.mdx Details the GithubProvider constructor and its configuration options. The provider is created by calling GithubProvider with a configuration object. ```APIDOC GithubProvider(config) - Creates a Github OAuth2 provider. - Parameters: - config (GithubConfig): The configuration object for the provider. - clientID (string): The client ID to identify your application. - clientSecret (string): The private key to authenticate your app; must be kept secret. - pkce? (boolean): Optional. Enables Proof Key for Code Exchange (PKCE) for the authorization code flow. Defaults to false. - query? (Record): Optional. Additional parameters to pass to the authorization endpoint. - scopes (string[]): An array of OAuth scopes to request from the user. - Returns: Provider Example Usage: ```ts GithubProvider({ clientID: "my-client-id", clientSecret: "my-client-secret", scopes: ["read:user", "user:email"] }) ``` ``` -------------------------------- ### Configuring GitHub Provider Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/issuer.mdx Example of how to configure the OpenAuth issuer to support the GitHub provider. It demonstrates importing the GithubProvider and passing it within the providers configuration object. ```ts import { GithubProvider } from "@openauthjs/openauth/provider/github" issuer({ providers: { github: GithubProvider() } }) ``` -------------------------------- ### VerifyError Structure and Usage Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/client.mdx Outlines the VerifyError structure, returned when a verification call fails. Similar to RefreshError, it specifies the type of error encountered, with a TypeScript example for type checking. ```ts ## VerifyError Returned when the verify call fails. err: The type of error that occurred. You can handle this by checking the type. ```ts import { InvalidRefreshTokenError } from "@openauthjs/openauth/error" console.log(err instanceof InvalidRefreshTokenError) ``` ``` -------------------------------- ### YahooProvider API and Configuration Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/provider/yahoo.mdx Details the YahooProvider's constructor signature, parameters, return types, and the YahooConfig interface, including descriptions for each configuration option. ```APIDOC YahooProvider(config) - Creates a Yahoo OAuth2 provider. - Parameters: - config: The configuration object for the provider, of type YahooConfig. - YahooConfig: - clientID: string - The client ID to identify your application. - clientSecret: string - The private key for authenticating your app; must be kept secret. - pkce?: boolean - Optional. Enables Proof Key for Code Exchange (PKCE) for the authorization code flow. Defaults to false. - query?: Record - Optional. Additional parameters to pass to the authorization endpoint. - scopes: string[] - An array of OAuth scopes to request. - Returns: Provider Example Usage: YahooProvider({ clientID: "1234567890", clientSecret: "0987654321" }) Example YahooConfig: { clientID: "my-client", clientSecret: "0987654321", pkce: true, query: { access_type: "offline", prompt: "consent" }, scopes: ["email", "profile"] } ``` -------------------------------- ### Configure MemoryStorage for testing Source: https://github.com/toolbeam/openauth/blob/master/README.md Demonstrates configuring the `storage` option for the `issuer` function, using `MemoryStorage` as an example. This is suitable for testing purposes, while production might use DynamoDB or Cloudflare KV. ```typescript import { MemoryStorage } from "@openauthjs/openauth/storage/memory" const app = issuer({ providers: { ... }, subjects, async success(ctx, value) { ... }, storage: MemoryStorage(), }) ``` -------------------------------- ### CSS Styles for Authentication Buttons Source: https://github.com/toolbeam/openauth/blob/master/www/src/content/docs/docs/start/standalone.mdx Defines the visual styling for primary and secondary action buttons used in the authentication flow. It includes properties for appearance, hover effects, and layout, ensuring a consistent user interface for login and logout actions. ```css .ctas button { appearance: none; background: transparent; border-radius: 128px; height: 48px; padding: 0 20px; border: none; border: 1px solid transparent; transition: background 0.2s, color 0.2s, border-color 0.2s; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 20px; font-weight: 500; } button.primary { background: var(--foreground); color: var(--background); gap: 8px; } button.secondary { border-color: var(--gray-alpha-200); min-width: 180px; } ```