Skip to main content

Client API Authentication

This guide helps you choose and implement the right authentication method for Glean's Client API, which powers search, chat, collections, agents, and other user-facing functionality.

OAuth (Recommended for per-user integrations)

Glean Authorization Server or your IdP

  • Tokens from the Glean OAuth Authorization Server or an external IdP
  • Works with Google, Azure, Okta, OneLogin
  • Glean-defined scopes (Authorization Server) or Client API access via your IdP
  • DCR for approved MCP hosts; static clients for governed applications

Setup OAuth →

Glean Tokens (Alternative)

Granular control and flexibility

  • Fine-grained scope control
  • User-scoped or global permissions
  • Manual token management
  • Best for specific use cases or testing

Setup Glean Tokens →


Quick Decision Guide

Choose your authentication method based on your needs:

Choose OAuth if you:

  • Are building a per-user Client API integration
  • Want users to authorize access without distributing Glean-issued API tokens
  • Can use the Glean OAuth Authorization Server (enabled by default) or already use supported OAuth tokens from your enterprise identity provider
  • Want the token issuer to manage expiration and refresh

Choose Glean-issued tokens if you:

  • Call the Indexing API, which does not accept OAuth
  • Need a global token with X-Glean-ActAs to impersonate users
  • Have no OAuth path: the Glean OAuth Authorization Server is disabled and no external-IdP OAuth path is configured

Authentication Headers Reference

Different authentication methods require different headers:

Authorization: Bearer <oauth_access_token>

Quick Start

1

Choose your authentication method

Use the decision guide above to pick OAuth or Glean tokens

2

Follow the detailed setup guide

3

Test your integration

Use the test commands in your chosen guide to verify authentication

4

Build your application

Start building with the Client API Reference


Testing Your Authentication

Use the Search API Explorer to test a Client API request against your own tenant. API Explorer tests Client API authentication only. It is not production sample code. Implement the OAuth flow and token handling in your application before you deploy.

Quick Test Commands

Replace <instance> with your Glean instance name (how to find):

curl -X POST https://<instance>-be.glean.com/rest/api/v1/search \
-H 'Authorization: Bearer <OAUTH_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"query": "test", "pageSize": 1}'

Expected Response

Successful authentication returns a 200 status with search results:

{
"results": [...],
"trackingToken": "...",
"requestId": "..."
}

Common Authentication Errors

ErrorLikely CauseSolution
401 UnauthorizedInvalid or expired tokenVerify token is correct and not expired
403 ForbiddenInsufficient permissionsCheck token scopes or OAuth settings
Missing X-Glean-Auth-Type header / Invalid SecretExternal-IdP OAuth token sent without the auth-type headerAdd X-Glean-Auth-Type: OAUTH (external-IdP tokens only; not needed for Glean Authorization Server tokens)
Required header missing: X-Glean-ActAsGlobal token header missingAdd X-Glean-ActAs: user@email.com

For detailed troubleshooting, see your specific authentication guide.


Best Practices

Security

  • Store tokens securely - Never commit tokens to version control
  • Use environment variables for token storage in applications
  • Implement proper error handling for authentication failures
  • Monitor token usage through appropriate admin consoles

Development

  • Test authentication first - Verify auth works before building features
  • Create separate tokens for development, staging, and production
  • Use descriptive names for tokens to track their purpose
  • Plan your architecture early - some settings cannot be changed later

Implementation Guides

Ready to implement? Choose your path:


Next Steps


Need Help?

  • Getting Started: Use the decision guide above to choose your path
  • Technical Issues: Check the detailed guides linked above
  • Admin Access: Contact your Glean administrator for token creation or OAuth setup
  • Community: Join discussions at community.glean.com