Skip to main content
GET
/
auth
/
github
GitHub Login
curl --request GET \
  --url https://api.example.com/auth/github
{
  "redirect": {},
  "error": {}
}

Overview

This endpoint redirects users to GitHub’s OAuth authorization page to begin the authentication process. After successful authorization, GitHub will redirect back to the callback endpoint with an authorization code.

Endpoint

endpoint
string
/auth/github

Authentication

No authentication required. This is the entry point for user authentication.

OAuth Scopes

The following GitHub OAuth scopes are requested:
  • user:email - Access to user’s email addresses

Request

cURL
curl -X GET https://api.diffy.com/auth/github
JavaScript
fetch('https://api.diffy.com/auth/github', {
  method: 'GET',
  redirect: 'follow'
})
.then(response => {
  // User will be redirected to GitHub OAuth
  console.log(response.url);
});
Python
import requests

response = requests.get('https://api.diffy.com/auth/github', allow_redirects=True)
print(f"Redirected to: {response.url}")

Response

redirect
302 Redirect
Redirects to GitHub OAuth authorization page

Redirect URL Format

https://github.com/login/oauth/authorize?client_id={GITHUB_CLIENT_ID}

Flow

  1. User initiates login by accessing /auth/github
  2. Server redirects to GitHub OAuth authorization page
  3. User authorizes the application on GitHub
  4. GitHub redirects back to /auth/callback with authorization code
  5. Callback endpoint exchanges code for user data and returns JWT token

Error Responses

error
500
Internal server error if GitHub OAuth configuration is invalid
Error Response
{
  "statusCode": 500,
  "message": "Internal server error",
  "error": "Internal Server Error"
}

Implementation Reference

Source: src/auth/auth.controller.ts:15-21
@Get('github')
@UseGuards(AuthGuard('github2'))
@Redirect(
  `https://github.com/login/oauth/authorize?client_id=${process.env.GITHUB_CLIENT_ID}`,
  302,
)
async GitHub() {}

Build docs developers (and LLMs) love