python-gitlab / python-gitlab

A python wrapper for the GitLab API.

Home Page:https://python-gitlab.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

personal_access_tokens.rotate(<ID>) 'dict' object has no attribute 'token'

FearTheBadger opened this issue · comments

Description of the problem, including code/CLI snippet

When using this labrary to rotate a personal access token, there is no token attribute to the resulting dict object.

Expected Behavior

That the new token is present in the object.

Actual Behavior

Taken from:
https://python-gitlab.readthedocs.io/en/stable/gl_objects/personal_access_tokens.html

new_token = gl.personal_access_tokens.rotate(1630)
print(new_token.token)
Traceback (most recent call last):
  File "blahblah/./rotate_token", line 12, in <module>
    print(new_token.token)
AttributeError: 'dict' object has no attribute 'token'

Specifications

  • python-gitlab version: 4.4.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 16.8.1-ee

It is a dictionary thus access is not done via attributes.

We might need to update the docs there a bit.

new_token = gl.personal_access_tokens.rotate(1630)
print(new_token["token"])

Thanks for the clarification.