How coding agents and CLI tools obtain a Padel API token for the user through a browser login.
Coding agents and CLI tools can obtain an API token on the user’s behalf with an OAuth 2.0 authorization code flow with PKCE, instead of asking the user to create one and paste it. The user signs in (or creates an account) in the browser and approves the request, and the agent receives a token identical to one created on the API Tokens page, with no expiration.
Register a client with a loopback redirect URI. The client_name is shown on the consent screen and becomes the token name on the API Tokens page, so use the name of the project the token is for.
Generate a random code_verifier and its code_challenge (BASE64URL(SHA256(code_verifier))), start the local listener on the redirect URI and open this URL in the user’s browser:
Once the user approves, the browser is redirected to the redirect URI with code and state. Keep the listener running until a request with the matching state arrives, and ignore any other request (such as /favicon.ico or a callback from an earlier attempt). Then exchange the code within 10 minutes:
Store access_token outside version control (for example, as PADEL_API_KEY in a git-ignored .env file) and send it in the Authorization header as described in Authentication.
scope=api is required to receive an API token. Each completed flow creates a new token and earlier tokens remain valid, so register a new client per project and revoke unused tokens on the API Tokens page.