Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
FearTheBadger opened this issue Apr 5, 2024 · 3 comments · Fixed by #2837
Closed

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

FearTheBadger opened this issue Apr 5, 2024 · 3 comments · Fixed by #2837
Labels

Comments

@FearTheBadger
Copy link

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
@JohnVillalovos
Copy link
Member

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

@nejch
Copy link
Member

nejch commented Apr 5, 2024

We might need to update the docs there a bit.

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

@FearTheBadger
Copy link
Author

Thanks for the clarification.

JohnVillalovos added a commit that referenced this issue Apr 5, 2024
Rotate token returns a dict. Change example to print the entire dict.

Closes: #2836
nejch pushed a commit that referenced this issue Apr 5, 2024
Rotate token returns a dict. Change example to print the entire dict.

Closes: #2836
cristianocasella pushed a commit to cristianocasella/python-gitlab that referenced this issue Apr 10, 2024
Rotate token returns a dict. Change example to print the entire dict.

Closes: python-gitlab#2836
TimKnight-DWP pushed a commit to TimKnight-DWP/python-gitlab that referenced this issue Apr 24, 2024
Rotate token returns a dict. Change example to print the entire dict.

Closes: python-gitlab#2836
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants