
Product
Socket Threat Intel Now Shows Which Malware Campaigns Were Blocked or Detected
Socket Threat Intel now shows which malware campaigns were blocked or detected in your organization, with links to scans and Firewall events.
@gleanwork/auth
Advanced tools
Authenticate with Glean from the command line or JavaScript, with tenant discovery, OAuth login, and automatic token refresh.
Requires Node.js 22.12.0 or newer.
npm install @gleanwork/auth
The JavaScript API is ESM-only.
Sign in with your work email and request the scopes your application needs:
npx glean-auth login --email you@example.com --scopes search
Print the current token for a shell command or non-JavaScript application:
export GLEAN_API_TOKEN="$(
npx glean-auth token --email you@example.com --scopes search
)"
You can also run the CLI without installing it in a project:
npx -y @gleanwork/auth login --email you@example.com --scopes search
| Command | Description |
|---|---|
login | Sign in with OAuth and save credentials. |
status | Show local authentication status without printing credentials. |
token | Print the current access token. |
logout | Remove the matching saved OAuth credentials. |
npx glean-auth status --email you@example.com --scopes search
npx glean-auth status --email you@example.com --scopes search --json
npx glean-auth token --email you@example.com --scopes search
npx glean-auth logout --email you@example.com --scopes search
token prints only the token and a trailing newline to stdout. It does not start an interactive login. Run login first or set GLEAN_API_TOKEN.
| Option | Description |
|---|---|
--email <address> | Discover the Glean tenant associated with an email address. |
--server-url <url> | Use an explicit Glean backend URL instead of tenant discovery. |
--scopes <scope,...> | Request OAuth scopes. This option is repeatable and case-sensitive. |
Use the lowercase scope names advertised by the Glean OAuth server, such as search, chat, or mcp.
Run npx glean-auth --help for shared options and the command list. Run npx glean-auth <command> --help for command-specific options.
OAuth is the recommended authentication method. login uses Authorization Code with PKCE and opens a browser for approval. If the tenant permits Dynamic Client Registration, the CLI registers a client automatically. Set GLEAN_OAUTH_CLIENT_ID when an administrator has provisioned a public OAuth client instead.
For CI or another non-interactive environment, set a user-scoped API token and the Glean backend URL:
export GLEAN_SERVER_URL=https://your-company-be.glean.com
export GLEAN_API_TOKEN=your-api-token
A non-empty GLEAN_API_TOKEN takes precedence when the package retrieves a token. The package does not validate the scopes or expiration of an API token.
The CLI chooses a tenant in this order:
--server-url--emailGLEAN_SERVER_URLOAuth always requests openid and offline_access in addition to the scopes passed through --scopes. A saved OAuth grant is reused only when it includes every requested scope.
The package exports two runtime functions and their supporting TypeScript types.
import { createGleanTokenProvider, discoverGleanTenant } from "@gleanwork/auth";
const tenant = await discoverGleanTenant("you@example.com");
const getAccessToken = createGleanTokenProvider({
serverUrl: tenant.serverUrl,
scopes: ["search"],
});
const token = await getAccessToken();
discoverGleanTenant(email) returns the canonical tenant instance and backend URL for an email address.
createGleanTokenProvider(options) returns a non-interactive () => Promise<string> callback. It uses GLEAN_API_TOKEN when set. Otherwise, it reuses or refreshes credentials created by glean-auth login.
The callback can be passed directly to the Glean TypeScript SDK:
import { Glean } from "@gleanwork/api-client";
import { createGleanTokenProvider } from "@gleanwork/auth";
const glean = new Glean({
serverURL: "https://your-company-be.glean.com",
apiToken: createGleanTokenProvider({
serverUrl: "https://your-company-be.glean.com",
scopes: ["search"],
}),
});
The CLI stores OAuth credentials under $XDG_STATE_HOME/glean-auth when XDG_STATE_HOME is an absolute path. Otherwise, it uses ~/.local/state/glean-auth.
On Unix, state directories use mode 0700 and credential files use mode 0600. The package does not read or write project .env files. status never prints tokens; token intentionally writes a token to stdout for scripts and pipelines.
See CONTRIBUTING.md for development setup and quality checks.
MIT, see LICENSE.
FAQs
OAuth authentication and tenant discovery for Glean developer tools.
The npm package @gleanwork/auth receives a total of 13 weekly downloads. As such, @gleanwork/auth popularity was classified as not popular.
We found that @gleanwork/auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.

Product
Socket Threat Intel now shows which malware campaigns were blocked or detected in your organization, with links to scans and Firewall events.

Security News
Fixes for eMudhra and Brotli are out. Getting them everywhere they’re needed means tracking down bundled libraries, runtimes, and certificate stores.

Threat Research
/Security News
Socket uncovered secret-stealing workflows that ran in LiteLLM’s GitHub repository 11 days before the supply chain attack on PyPI and Docker.