OAuth Endpoints#
Complete reference for OAuth 2.1 endpoints implemented by the Auth service.
Endpoint Overview#
Endpoint |
Method |
Purpose |
Authentication |
---|---|---|---|
|
GET |
Start authorization flow |
None |
|
POST |
Exchange code for token |
Client credentials |
|
GET |
OAuth callback handler |
None (internal) |
|
POST |
Revoke token |
Client credentials |
|
POST |
Token introspection |
Client credentials |
|
GET |
Server metadata |
None |
Token Endpoint#
POST /token
#
Exchanges authorization code for access token.
Request Parameters#
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
string |
Yes |
|
|
string |
Yes |
Client identifier |
|
string |
No |
Required for confidential clients |
|
string |
Yes* |
Authorization code (*for auth code grant) |
|
string |
Yes* |
Must match authorize request |
|
string |
Yes* |
PKCE verifier |
|
string |
Yes** |
For refresh grant (**) |
Example Request (Refresh Token)#
POST /token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&
client_id=client_7d8e9f0a&
refresh_token=refresh_8d4b2c7e
Success Response#
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
"token_type": "Bearer",
"expires_in": 2592000,
"refresh_token": "refresh_8d4b2c7e",
"scope": "mcp:*"
}
Error Response#
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": "invalid_grant",
"error_description": "Authorization code is invalid or expired"
}
Callback Endpoint#
GET /callback
#
Internal endpoint for GitHub OAuth callback processing.
Request Parameters#
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
string |
Yes |
GitHub authorization code |
|
string |
Yes |
State from original request |
Flow#
Receives callback from GitHub
Validates state parameter
Exchanges GitHub code for user info
Generates authorization code
Redirects to client callback
This endpoint is not called directly by clients.
Revocation Endpoint#
POST /revoke
#
Revokes an access or refresh token.
Request Parameters#
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
string |
Yes |
Token to revoke |
|
string |
No |
|
|
string |
Yes |
Client identifier |
|
string |
No |
For confidential clients |
Example Request#
POST /revoke
Content-Type: application/x-www-form-urlencoded
token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...&
token_type_hint=access_token&
client_id=client_7d8e9f0a
Response#
HTTP/1.1 200 OK
Content-Type: application/json
{
"status": "revoked"
}
Note: Always returns 200 OK per RFC 7009, even if token was already revoked or invalid.
Introspection Endpoint#
POST /introspect
#
Returns token metadata and validation status.
Request Parameters#
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
string |
Yes |
Token to introspect |
|
string |
No |
|
|
string |
Yes |
Client identifier |
|
string |
No |
For confidential clients |
Example Request#
POST /introspect
Content-Type: application/x-www-form-urlencoded
token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...&
client_id=client_7d8e9f0a
Active Token Response#
HTTP/1.1 200 OK
Content-Type: application/json
{
"active": true,
"scope": "mcp:*",
"client_id": "client_7d8e9f0a",
"username": "github|johndoe",
"token_type": "Bearer",
"exp": 1706745600,
"iat": 1704153600,
"sub": "github|johndoe",
"aud": "client_7d8e9f0a",
"iss": "https://auth.example.com",
"jti": "token_3f8a9c2d"
}
Inactive Token Response#
HTTP/1.1 200 OK
Content-Type: application/json
{
"active": false
}
Discovery Endpoint#
Authentication Methods#
Public Clients#
Public clients (mobile apps, SPAs) use:
No client secret required
PKCE mandatory
token_endpoint_auth_method
:none
Confidential Clients#
Confidential clients use:
Client secret required
Supported methods:
client_secret_post
- In request bodyclient_secret_basic
- HTTP Basic auth
PKCE Implementation#
Code Verifier Generation#
import secrets
import base64
# Generate code verifier (43-128 characters)
code_verifier = base64.urlsafe_b64encode(
secrets.token_bytes(32)
).decode('utf-8').rstrip('=')
Code Challenge Generation#
import hashlib
# Generate S256 challenge
code_challenge = base64.urlsafe_b64encode(
hashlib.sha256(code_verifier.encode()).digest()
).decode('utf-8').rstrip('=')
Security Headers#
All OAuth endpoints include security headers:
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Error Handling#
OAuth errors follow RFC 6749 format:
Error Code |
Description |
---|---|
|
Request missing required parameter |
|
Client authentication failed |
|
Authorization code or refresh token invalid |
|
Client not authorized for grant type |
|
Grant type not supported |
|
Requested scope invalid or exceeds granted |