Start the authorization code flow and issue a code
Start the authorization code flow and issue a code (auto-approved as user apibee).
Codes are single use and expire after 10 minutes. Exchange them at POST /api/auth/oauth/token.Codes are single use and expire after 10 minutes. Exchange them at POST ….
Note: PKCE: code_challenge = base64url(SHA-256(code_verifier)). Registered redirect URIs (localhost, 127.0.0.1, Postman, this server's Swagger) get a 302. Any other redirect_uri is refused with 400 invalid_request and no code is issued. Leave redirect_uri out to get the code as JSON.
Parameters 7
| Name | Type | Description |
|---|---|---|
response_type | query · string | Must be code. |
client_id | query · string | apibee-client (confidential) or apibee-public (public; PKCE required). |
redirect_uri | query · string | Where to send the code. Registered: http(s) URIs on localhost or 127.0.0.1 (any port) and the Postman callbacks. Any other value is refused with 400 and no code is issued; leave it out to get the code as JSON. |
scope | query · string | Space-separated subset of the client's scopes (apibee-client: read write profile email; apibee-public: read profile email). Defaults to all of them. |
state | query · string | Opaque value echoed back unchanged. |
code_challenge | query · string | PKCE challenge: BASE64URL(SHA256(code_verifier)) for S256, or the verifier itself for plain. |
code_challenge_method | query · string | S256 or plain (default plain). |
Responses
- 200
- Code returned as JSON (no redirect_uri sent).
- 302
- Redirect to redirect_uri with code and state.
- 400
- invalid_client, unsupported_response_type, invalid_request (including an unregistered redirect_uri) or invalid_scope.
Example
curl -X GET "https://api.testingapis.com/api/auth/oauth/authorize?response_type=code&client_id=apibee-public&redirect_uri=http://localhost:3000/callback&state=xyz&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256" \
-H "X-TestingApis-Key: YOUR_API_KEY"Location: http://localhost:3000/callback?code=code_3d7eac7eaf6981c2de11965a88d969531cf9a9c3&state=xyz
Sign in to see the details
The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.