App Integration Guide: Secure Authorization with OAuth and PKCE

2026-11-11 · 原创·功能教程

App Integration Guide: Secure Authorization with OAuth and PKCE

For application developers needing authorization, tiered calls, and app-scoped usage, secure app integration is the foundation of your service. This tutorial will guide you through the preparation, operation, result viewing, and security practices for authorizing your application.

Preparation

Before starting, ensure you understand the core requirements for app integration. This feature uses the OAuth authorization code flow with PKCE (Proof Key for Code Exchange). If you are developing a public client, you must use S256 for the PKCE method. Review the necessary scopes based on your business logic and remember to request only required scopes.

Operation Steps

1. Initiate Authorization Request: Redirect the user to the authorization page to request specific scopes. Ensure you are only asking for the minimum scopes required for your business.

2. Handle Authorization Code and PKCE: Once the user authorizes the application, an authorization code is returned. During this exchange, public clients must use S256 for PKCE verification to secure the request.

3. Obtain Access Token: Exchange the authorization code along with the PKCE verifier to obtain the access token for subsequent API calls.

Result Viewing and Usage Management

After successfully obtaining the token, you can make API calls within your application. Note that balance and usage scopes are separate. If you need to view app-scoped usage, ensure you have requested the appropriate usage scope during authorization. This allows you to effectively manage tiered calls and monitor application usage.

Security Precautions

Security is critical during app integration. Always adhere to the following rules:

  • Protect ext tokens: Never expose ext tokens in browser code. Doing so creates a severe risk of token leakage.
  • Scope Separation: Since balance and usage scopes are separate, assign them strictly based on your needs to avoid over-authorization.
  • Principle of Least Privilege: Always request only required scopes to minimize potential security risks.

To explore more about the API specifications and parameters, visit the model plaza or the corresponding tool experience, and navigate to `/docs#docs-oauth` within the platform for comprehensive documentation.