4

集成指南

使用以下信息将 OAuth 集成到您的应用中

环境变量
CLIENT_ID=app_3f8a2b1c9d4e
CLIENT_SECRET=sk_••••••••••••
REDIRECT_URL=https://myapp.com/callback
快速开始
const authUrl = `https://auth.example.com/authorize`
  + `?client_id=${CLIENT_ID}`
  + `&redirect_uri=${REDIRECT_URL}`
  + `&response_type=code`
  + `&scope=openid profile`;

// 引导用户完成授权
window.location.href = authUrl;
import requests

auth_url = (
    f"https://auth.example.com/authorize"
    f"?client_id={CLIENT_ID}"
    f"&redirect_uri={REDIRECT_URL}"
    f"&response_type=code"
    f"&scope=openid profile"
)

# 使用授权码换取令牌
resp = requests.post("https://auth.example.com/token", data={
    "grant_type": "authorization_code",
    "code": code,
    "client_id": CLIENT_ID,
    "client_secret": CLIENT_SECRET,
})
完整 API 文档 OAuth Playground 技术支持
查看应用详情