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)

Leverages your existing identity provider

  • No token management required
  • Works with Google, Azure, Okta, OneLogin
  • Full API access without scope restrictions
  • Best for production 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:

  • Have an existing identity provider (Google, Azure, Okta, OneLogin)
  • Want full Client API access without managing scopes
  • 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

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

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 headerOAuth header not setAdd X-Glean-Auth-Type: OAUTH for OAuth
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