AttibuteError when trying to get personal_access_token when using python-gitlab library

35 Views Asked by At

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

There are 1 best solutions below

2
nejc On

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