OAuth & SSO
This guide explains how to integrate your application with AutoGPT Platform using OAuth 2.0. OAuth can be used for API access, Single Sign-On (SSO), or both.
For general API information and endpoint documentation, see the API Guide and the Swagger documentation.
Overview
AutoGPT Platform's OAuth implementation supports multiple use cases:
OAuth for API Access
Use OAuth when your application needs to call AutoGPT APIs on behalf of users. This is the most common use case for third-party integrations.
When to use:
Your app needs to run agents, access the store, or manage integrations for users
You want user-specific permissions rather than a single API key
Users should be able to revoke access to your app
SSO: "Sign in with AutoGPT"
Use SSO when you want users to sign in to your app through their AutoGPT account. Request the IDENTITY scope to get user information.
When to use:
You want to use AutoGPT as an identity provider
Users already have AutoGPT accounts and you want seamless login
You need to identify users without managing passwords
Note: SSO and API access can be combined. Request IDENTITY along with other scopes to both authenticate users and access APIs on their behalf.
Integration Setup Wizard
A separate flow that guides users through connecting third-party services (GitHub, Google, etc.) to their AutoGPT account. See Integration Setup Wizard below.
Prerequisites
Before integrating, you need an OAuth application registered with AutoGPT Platform. Contact the platform administrator to obtain:
Client ID - Public identifier for your application
Client Secret - Secret key for authenticating your application (keep this secure!)
Registered Redirect URIs - URLs where users will be redirected after authorization
OAuth Flow
The OAuth flow is technically the same whether you're using it for API access, SSO, or both. The main difference is which scopes you request.
Step 1: Redirect User to Authorization
Redirect the user to the AutoGPT authorization page with the required parameters:
Parameters
client_id
Yes
Your OAuth application's client ID
redirect_uri
Yes
URL to redirect after authorization (must match registered URI)
state
Yes
Random string to prevent CSRF attacks (store and verify on callback)
code_challenge_method
Yes
Must be S256
response_type
Yes
Must be code
Step 2: Handle the Callback
After the user approves (or denies) access, they'll be redirected to your redirect_uri:
Success:
Error:
Always verify the state parameter matches what you sent in Step 1.
Step 3: Exchange Code for Tokens
Exchange the authorization code for access and refresh tokens:
Response:
Step 4: Use the Access Token
Include the access token in API requests:
For SSO: If you requested the IDENTITY scope, fetch user info to identify the user:
Response:
See the Swagger documentation for all available endpoints.
Step 5: Refresh Tokens
Access tokens expire after 1 hour. Use the refresh token to get new tokens:
Response:
Integration Setup Wizard
The Integration Setup Wizard guides users through connecting third-party services (like GitHub, Google, etc.) to their AutoGPT account. This is useful when your application needs users to have specific integrations configured.
Redirect to the Wizard
Parameters
client_id
Yes
Your OAuth application's client ID
providers
Yes
Base64-encoded JSON array of provider configurations
redirect_uri
Yes
URL to redirect after setup completes
state
Yes
Random string to prevent CSRF attacks
Provider Configuration
The providers parameter is a Base64-encoded JSON array:
Handle the Callback
After setup completes:
Success:
Failure/Cancelled:
Provider Scopes Reference
When using the Integration Setup Wizard, you need to specify which scopes to request from each provider. Here are common providers and their scopes:
GitHub
Documentation: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
repo
Full control of private repositories
read:user
Read user profile data
user:email
Access user email addresses
gist
Create and manage gists
workflow
Update GitHub Actions workflows
Example:
Google
Documentation: https://developers.google.com/identity/protocols/oauth2/scopes
email
View email address (default)
profile
View basic profile info (default)
openid
OpenID Connect (default)
https://www.googleapis.com/auth/calendar
Google Calendar access
https://www.googleapis.com/auth/drive
Google Drive access
https://www.googleapis.com/auth/gmail.readonly
Read Gmail messages
Example:
Notion
Documentation: https://developers.notion.com/reference/capabilities
Notion uses a single OAuth scope that grants access based on pages the user selects during authorization.
Linear
Documentation: https://developers.linear.app/docs/oauth/authentication
read
Read access to Linear data
write
Write access to Linear data
issues:create
Create issues
PKCE Implementation
PKCE (Proof Key for Code Exchange) is required for all authorization requests. Here's how to implement it:
JavaScript Example
Python Example
Token Management
Token Lifetimes
Access Token
1 hour
Refresh Token
30 days
Authorization Code
10 minutes
Token Introspection
Check if a token is valid:
Response:
Token Revocation
Revoke a token when the user logs out:
Security Best Practices
Store client secrets securely - Never expose them in client-side code or version control
Always use PKCE - Required for all authorization requests
Validate state parameters - Prevents CSRF attacks
Use HTTPS - All production redirect URIs must use HTTPS
Request minimal scopes - Only request the permissions your app needs
Handle token expiration - Implement automatic token refresh
Revoke tokens on logout - Clean up when users disconnect your app
Error Handling
Common OAuth Errors
invalid_client
Client ID not found or inactive
Verify client ID is correct
invalid_redirect_uri
Redirect URI not registered
Register URI with platform admin
invalid_scope
Requested scope not allowed
Check allowed scopes for your app
invalid_grant
Code expired or already used
Authorization codes are single-use
access_denied
User denied authorization
Handle gracefully in your UI
HTTP Status Codes
200
Success
400
Bad request (invalid parameters)
401
Unauthorized (invalid/expired token)
403
Forbidden (insufficient scope)
404
Resource not found
Support
For issues or questions about OAuth integration:
Open an issue on GitHub
See the API Guide for general API information
Check the Swagger documentation for endpoint details
Last updated
Was this helpful?