OAuth 2.1 Token Endpoint implementation guide. Use when implementing token endpoint requirements beyond OpenID Connect, including grant types, token response format, Cache-Control headers, CORS support, and error handling. Covers OAuth 2.1 Section 3.2 and Section 4 requirements.
Click "Upload skill" and select the downloaded ZIP file
Note: Please verify skill by going through its instructions before using it.
SKILL.md
name
oauth21-token-endpoint
description
OAuth 2.1 Token Endpoint implementation guide. Use when implementing token endpoint requirements beyond OpenID Connect, including grant types, token response format, Cache-Control headers, CORS support, and error handling. Covers OAuth 2.1 Section 3.2 and Section 4 requirements.
OAuth 2.1 Token Endpoint
Token Endpoint requirements specific to OAuth 2.1 (beyond OpenID Connect).
Endpoint Requirements
HTTP Method
MUST use POST method
Other methods not allowed
Content Type
MUST accept application/x-www-form-urlencoded
UTF-8 character encoding
TLS
MUST use HTTPS
Except localhost for development
CORS Support
For browser-based apps:
Token endpoint MUST support CORS headers
Return appropriate Access-Control-Allow-Origin
HTTP/1.1 200 OK
Access-Control-Allow-Origin: https://client.example.com
Content-Type: application/json
Supported Grant Types
authorization_code
POST /token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=SplxlOBeZQQYbYS6WxSbIA
&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
refresh_token
POST /token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token
&refresh_token=tGzv3JOkF0XG5Qx2TlKWIA
client_credentials
POST /token HTTP/1.1
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
Token Request Processing
Client Authentication
def process_token_request(request):
# 1. Authenticate confidential clients
if client.is_confidential:
if not authenticate_client(request):
return error_response("invalid_client")
# 2. Validate grant type specific parameters
# 3. Issue tokens
def handle_code_reuse(code):
if code.already_used:
# MUST deny request
# SHOULD revoke all tokens from this code
revoke_tokens_for_code(code)
return error_response("invalid_grant")
Refresh Token Grant Specifics
Request Parameters
Parameter
Requirement
grant_type
REQUIRED. Value: refresh_token
refresh_token
REQUIRED. The refresh token
scope
OPTIONAL. Must not exceed original scope
Public Client Requirements
For public clients, refresh tokens MUST be either: