FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
c15r

c15r

GHauth

Public
Like
1
GHauth
Home
Code
4
backend
1
frontend
1
shared
1
README.md
Branches
1
Pull requests
Remixes
History
Environment variables
3
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
5/27/2025
Viewing readonly version of main branch: v12
View latest version
README.md

GitHub OAuth Authentication Service

A Val Town service for handling GitHub OAuth authentication with redirect support for external applications.

Features

  • GitHub OAuth sign-in flow
  • JWT token generation for authenticated users
  • Redirect support for external applications
  • Secure token validation
  • User profile retrieval

Setup

  1. Create a GitHub OAuth App:

    • Go to GitHub Settings > Developer settings > OAuth Apps
    • Create a new OAuth App
    • Set Authorization callback URL to: https://[your-val-url]/auth/callback
  2. Set environment variables in Val Town:

    • GITHUB_CLIENT_ID: Your GitHub OAuth app client ID
    • GITHUB_CLIENT_SECRET: Your GitHub OAuth app client secret
    • JWT_SECRET: A secure random string for signing JWT tokens

Usage

Sign In Flow

  1. Redirect users to: https://[your-val-url]/auth/signin?redirect_uri=[your-app-url]
  2. Users will be redirected to GitHub for authentication
  3. After successful auth, users are redirected back to your app with a token: [your-app-url]?token=[jwt-token]

Token Validation

Make a GET request to: https://[your-val-url]/auth/validate?token=[jwt-token]

Returns user profile if token is valid.

API Endpoints

  • GET /auth/signin - Initiate GitHub OAuth flow
  • GET /auth/callback - Handle GitHub OAuth callback
  • GET /auth/validate - Validate JWT token and return user info
  • GET / - Auth page UI

File Structure

  • /backend/index.ts - Main Hono server with OAuth routes
  • /frontend/index.html - Auth page UI
  • /shared/types.ts - Shared TypeScript types
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.