INNER CODE UNIT · Python
validate_auth
phasehq/console · backend/api/utils/syncing/gitlab/main.py:79
def validate_auth(credential_id):
"""
Check if the GitLab token is valid and operational.
This function makes a request to the GitLab API to fetch the user's details.
A successful request (status code 200) indicates a valid token.
"""
GITLAB_HOST, GITLAB_TOKEN = get_gitlab_credentials(credential_id)
headers = {"Private-Token": GITLAB_TOKEN}
response = requests.get(f"{GITLAB_HOST}/api/v4/user", headers=headers)
return response.status_code == 200
def list_gitlab_projects(credential_id):
"""
List all GitLab repositories the user has access to with CRUD permissions on CI/CD variables.