0

I'm trying to perform a basic task of getting the logged in users GitLab personal access token using the python-gitlab library. The documentation here is what I am using in the code below - https://python-gitlab.readthedocs.io/en/stable/gl_objects/personal_access_tokens.html

But I get...

token = gl.personal_access_tokens.get("self")

AttributeError: 'PersonalAccessTokenManager' object has no attribute 'get'

Any help would be greatly appreciated! Thanks

1 Answer 1

0

You're using an old version of python-gitlab. You'll need to upgrade to at least v3.14.0, released in April 2023, where support for this GET endpoint was added.

https://github.com/python-gitlab/python-gitlab/releases/tag/v3.14.0

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot for pointing that out, nejc! For now I am stuck using python-gitlab 3.11. Do you know if there is functionality available in this release to rotate a personal access token? Thanks again for your help
The rotate token API was added in v4.4.0, so you'd also need to upgrade. You can probably upgrade by installing it from pypi (either via pip or other python package manager) rather than using an OS-level package manager. There are workarounds by using the lower-level methods likeGitlab.http_get() directly but ideally you just use more recent version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.