Skip to content

GitLab OAuth tokens expire after 2 hours - implement refresh token support #14

@Mic92

Description

@Mic92

Problem

GitLab OAuth access tokens expire after 2 hours by default (some configurations may allow up to 1 day). Currently, nix-auth does not capture or use the refresh_token that GitLab returns in the OAuth response, so users need to re-authenticate frequently.

Current behavior

The gitLabTokenResponse struct only captures:

  • access_token
  • token_type
  • expires_in
  • scope

GitLab actually returns additional fields including refresh_token which is ignored.

Proposed solution

Implement refresh token support:

  1. Capture refresh_token from GitLab's token response
  2. Store refresh tokens in a metadata file (e.g., ~/.config/nix/nix-auth-metadata.json) since access-tokens.conf only supports simple host=token format
  3. Add nix-auth refresh command to manually refresh tokens before they expire
  4. Auto-refresh on nix-auth status when tokens are near expiration (optional)

References

Related

Reported as follow-up to #7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions