使用以下信息将 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, })