GitHub
Integrate GitHub OAuth2 authentication into your application.
Setup Guide
1. Create GitHub OAuth App
- Go to GitHub Settings → Developer settings → OAuth Apps
- Click New OAuth App
- Fill in the details:
- Application name: Your app name
- Homepage URL:
http://localhost:3000 - Authorization callback URL:
http://localhost:3000/auth/github/callback
- Click Register application
- Copy the Client ID
- Generate a Client Secret and copy it
Keep Your Secret Safe
Never commit your client secret to version control. Use environment variables.
2. Configure Environment
AUTHKESTRA_GITHUB_CLIENT_ID=your_client_id
AUTHKESTRA_GITHUB_CLIENT_SECRET=your_client_secret
AUTHKESTRA_GITHUB_REDIRECT_URI=http://localhost:3000/auth/github/callback3. Implementation
use authkestra_flow::OAuth2Flow;
use authkestra_providers_github::GithubProvider;
// Create the provider
let provider = GithubProvider::new(
std::env::var("AUTHKESTRA_GITHUB_CLIENT_ID").unwrap(),
std::env::var("AUTHKESTRA_GITHUB_CLIENT_SECRET").unwrap(),
std::env::var("AUTHKESTRA_GITHUB_REDIRECT_URI")
.unwrap_or_else(|_| "http://localhost:3000/auth/github/callback".to_string()),
);
// Add to Authkestra
let authkestra = Authkestra::builder()
.provider(OAuth2Flow::new(provider))
.session_store(Arc::new(authkestra_session::MemoryStore::default()))
.build();Available Scopes
| Scope | Description |
|---|---|
user | Read/write access to profile info |
user:email | Read access to user's email addresses |
read:user | Read access to profile info (default) |
repo | Full control of private repositories |
// Request specific scopes
let flow = OAuth2Flow::new(provider)
.with_scopes(vec!["read:user", "user:email"]);Identity Attributes
GitHub provider populates these additional attributes:
// Available in identity.attributes
let avatar_url = identity.attributes.get("avatar_url");
let html_url = identity.attributes.get("html_url"); // GitHub profile URL
let company = identity.attributes.get("company");
let location = identity.attributes.get("location");
let bio = identity.attributes.get("bio");