App Integration OAuth Tutorial: Authorize Users with Authorization Code and PKCE
2026-11-29 · 原创·功能教程
App Integration: Let Users Authorize Your Application
This tutorial is for developers who are new to AI platform app integration. It explains how to let users authorize your application, how to request only the scopes your business needs, and how to check app-scoped usage. The documented entry point is `/docs#docs-oauth`. The article covers preparation, operation, result checks, and safety for developers and enterprise readers.
Preparation
1. Start with `/docs#docs-oauth` and follow the documented OAuth app integration requirements.
2. Define the scopes your business actually needs. Request only the minimum scopes required.
3. Treat balance and usage permissions as separate. The ext balance and usage scopes are independent, so do not assume one scope covers the other.
4. Determine your client type. Public clients must use S256.
Operation
1. Use the OAuth authorization code flow with PKCE, following the documentation.
2. For public clients, use S256. Do not skip the PKCE requirement.
3. Include only the scopes required by your business in the authorization request. If balance or usage access is needed, evaluate each permission separately.
4. After the user authorizes, complete the authorization code and token handling as described in the documentation. Never expose ext tokens in logs, public code, or untrusted scripts. Server-side clients must keep tokens on the server; browser-based public clients must use PKCE and secure token storage.
5. When your application makes calls, rely on the scope the user actually authorized. Do not assume that unrequested scopes are available.
Checking Results
After authorization, follow the documentation to check app-scoped usage. Because balance and usage scopes are separate, do not use one permission to judge whether the other was granted. For tiered calls, verify against the authorized scopes and the documentation rather than inferring tiers or limits. Specific fields and locations are defined by `/docs#docs-oauth`.
Safety Notes
- Request only the minimum scopes required by your business.
- Never expose ext tokens in logs, public code, or untrusted scripts. Browser-based public clients must use PKCE and secure storage; server-side clients must not send tokens to the browser.
- Public clients must use S256.
- Balance and usage scopes are separate; request and verify them independently.
- Do not promise automation, free quota, or success rates that are not provided in the documentation.
When these steps are complete, return to `/docs#docs-oauth` to review authorization, scopes, and token handling, then continue with the model catalog or the corresponding tool.