module

Comrade

Comrade - A Crystal OAuth library inspired by Laravel Socialite

Comrade provides a simple, elegant interface for OAuth authentication with various providers like GitHub, Google, Facebook, and more.

Example: github = Comrade.driver(Provider::Github) auth_url = github.redirect(scopes: ["user:email"]) user = github.user(callback_code)

Constants

VERSION = "0.1.0"

Class methods

config

Get the current manager configuration

Source
configure

Configure global settings

Example: Comrade.configure { |config| config.http_timeout = 30 }

Source
driver(provider : Provider)

Main manager for accessing OAuth providers

Returns a provider instance for the given driver

Examples: github = Comrade.driver(Provider::Github) google = Comrade.driver(:google) # Symbol automatically converts to Provider::Google

Source
provider_configured?(provider : Provider) : Bool

Check if a provider is configured

Examples: Comrade.provider_configured?(Provider::Github) Comrade.provider_configured?(:google) # Symbol automatically converts

Source
register_provider(provider : Provider, client_id_env : String, client_secret_env : String | Nil = nil, redirect_uri : String = "", scopes : Array(String) = [] of String)

Register a provider configuration from environment variables

Examples: Comrade.register_provider(Provider::Github, "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET") Comrade.register_provider(:google, "GOOGLE_CLIENT_ID") # Symbol automatically converts

Source
remove_provider(name : String)

Remove a provider configuration

Source

Nested types