Skip to main content
API Overview/Authentication

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)

Glean Authorization Server or your IdP

  • Tokens from the Glean OAuth Authorization Server (incl. DCR) or an external IdP
  • Works with Google, Azure, Okta, OneLogin
  • Glean-defined scopes (Authorization Server) or Client API access via your IdP
  • Powers the remote MCP server

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:

  • Have an existing identity provider (Google, Azure, Okta, OneLogin)
  • Want standards-based authentication without creating Glean tokens
  • Prefer leveraging existing enterprise authentication
  • Need production-ready authentication quickly

Choose Glean Tokens if you:

  • Need granular scope control for security
  • Don't have an OAuth identity provider
  • Need global permissions to impersonate users
  • Want fine-grained control over token lifecycle

Authentication Headers Reference

Different authentication methods require different headers:

Authorization: Bearer <oauth_access_token>
X-Glean-Auth-Type: OAUTH # required for external-IdP tokens; optional for Glean Authorization Server tokens

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

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 'X-Glean-Auth-Type: OAUTH' \
-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