OAuth PKCE
Users can connect to Glama Gateway in one click using Proof Key for Code Exchange (PKCE).
Implementation Steps
Step 1: Direct your user to authorization URL
Redirect your user to the following URL:
https://glama.ai/oauth/authorize
Using S256 code_challenge
Include these parameters in the URL:
code_challenge=CODE_CHALLENGE
code_challenge_method=S256
Generate the code_challenge
using S256:
Store the value of codeVerifier
and use it in the Step 2.
Example:
https://glama.ai/oauth/authorize
Step 2: Exchange the authorization code for an API key
After the user logs in, they will be redirected back to your site with an authorization code
included in the URL as a query parameter. Use this code
to exchange it for a user-controlled API key.
Step 3: Use the API key
The API key will be returned in the response under the key apiKey
. Store it securely and use it to authenticate requests against Glama's OpenAI-compatible gateway:
You can use libraries compatible with the OpenAI API, such as openai (for JavaScript) or openai (for Python).
Need help?
If you have any questions or need help, reach out to our support.