glab-auth
glab auth
Current captured help and immutable provenance: command reference. Older command captures retain their original provenance and describe earlier interfaces.
Manage GitLab CLI authentication.
OAuth client-ID preflight
Before browser OAuth login, glab checks the public client ID against the instance's token endpoint using a deliberately invalid authorization code. An HTTP 400/401 invalid_client rejects the ID before opening the browser. The request has a five-second timeout and does not follow redirects; network failures, other responses, or an unreadable error body let the normal login flow continue. Passing the preflight is not successful authentication. Do not manually probe token endpoints or supply application secrets to diagnose this check; login and credential storage still require the existing authorization.
OAuth validation and recovery
GitLab.com always uses the built-in OAuth client ID; a configured client_id or GITLAB_CLIENT_ID does not override it. Self-Managed/Dedicated application IDs are trimmed and validated before opening a browser/device flow. Supply the public Application ID, not an application secret.
An invalid_grant during refresh first allows bounded rereads for credentials rotated by another process. If the failed refresh token is still current, glab clears it so subsequent calls do not resend it; transient failures do not clear it. Stop repeated failing operations and arrange explicitly approved reauthentication for that exact host. Do not print stored tokens or automatically broaden credential-helper scope.
For an SSH remote on a subdomain of a configured GitLab host, the diagnostic can suggest ssh_host. Verify those hosts represent the same instance before approving the mapping; a subdomain can be a separate instance, and glab does not silently infer trust.