Agent Auth is in Beta and under active development. To provide feedback or use this feature, reach out to the LangChain team.
Installation
- Python
- JavaScript
Quickstart
1. Initialize the client
- Python
- JavaScript
Self-hosted configuration
For self-hosted LangSmith instances, specify the API URL using the/api-host path on your instance.
- Environment Variable
- Explicit Configuration (Python)
- Explicit Configuration (JavaScript)
2. Set up OAuth providers
Before agents can authenticate, you need to configure an OAuth provider using the following process:- Select a unique identifier for your OAuth provider to use in LangChain’s platform (e.g., “github-local-dev”, “google-workspace-prod”).
- Go to your OAuth provider’s developer console and create a new OAuth application.
- Set the callback URL in your OAuth provider:
- LangSmith Cloud
- Self-hosted
- Use
client.create_oauth_provider()with the credentials from your OAuth app:
- Python
- JavaScript
3. Authenticate from an agent
The clientauthenticate() API is used to get OAuth tokens from pre-configured providers. On the first call, it takes the caller through an OAuth 2.0 auth flow.
In LangGraph context
By default, tokens are scoped to the calling agent using the Assistant ID parameter.
Studio interrupt showing OAuth URL

GitHub OAuth success page
Outside LangGraph context
Provide theauth_url to the user for out-of-band OAuth flows.
- Python
- JavaScript
Troubleshooting
Self-hosted: 405 Method Not Allowed
If you receive a405 Method Not Allowed error, ensure LANGSMITH_API_URL points to the /api-host path: