Skip to content

Comments

Convert GitLab web URLs to API format for authentication#58

Merged
alex-feel merged 1 commit intomainfrom
alex-feel-dev
Sep 5, 2025
Merged

Convert GitLab web URLs to API format for authentication#58
alex-feel merged 1 commit intomainfrom
alex-feel-dev

Conversation

@alex-feel
Copy link
Owner

The issue was that GitLab web UI raw URLs (/-/raw/) don't accept API tokens via headers. Only the GitLab API endpoints accept PRIVATE-TOKEN headers for authentication.

Changes:

  • Add convert_gitlab_url_to_api() function to transform web URLs to API format
  • Automatically convert GitLab URLs in fetch_url_with_auth() before fetching
  • Update README with clear examples of both web and API URL formats
  • Document that web URLs are automatically converted for authentication

Converts from: https://gitlab.com/namespace/project/-/raw/branch/path
To: https://gitlab.com/api/v4/projects/namespace%2Fproject/repository/files/path/raw?ref=branch

The issue was that GitLab web UI raw URLs (/-/raw/) don't accept API tokens via headers.
Only the GitLab API endpoints accept PRIVATE-TOKEN headers for authentication.

Changes:
- Add convert_gitlab_url_to_api() function to transform web URLs to API format
- Automatically convert GitLab URLs in fetch_url_with_auth() before fetching
- Update README with clear examples of both web and API URL formats
- Document that web URLs are automatically converted for authentication

Converts from: https://gitlab.com/namespace/project/-/raw/branch/path
To: https://gitlab.com/api/v4/projects/namespace%2Fproject/repository/files/path/raw?ref=branch
@alex-feel alex-feel enabled auto-merge September 5, 2025 11:07
@alex-feel alex-feel merged commit 05aaf34 into main Sep 5, 2025
5 checks passed
@alex-feel alex-feel deleted the alex-feel-dev branch September 5, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant