Request to /api/users/tokens/ using Python not returning results #10796
dan-tabarca
started this conversation in
General
Replies: 2 comments
-
Access to /api paths requires either an Authorization: Token $value or an active session cookie, there is no login form to submit username, password fields to.
The workflow is for a human to copy/paste the token from the web UI into somewhere your API client can access it, a config file, environment variable, hardcoded into the script, etc. then the API client includes the "Authorization: Token $token_value" header in every request which will identify and authorize the request.
the /api/users/token API endpoint is provided if you need an API client to be privileged to read tokens for other accounts or do account management, eg an API proxy/broker that can behave with the privileges of another authenticated user by using a privileged API account to read the token for another user, then perform further requests _as_ _that_ _user_ to be constrained by roles, groups, permissions in Netbox.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: dan-tabarca ***@***.***>
Sent: Monday, October 31, 2022 9:04 AM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Request to /api/users/tokens/ using Python not returning results (Discussion #10796)
I've been trying to get the already created tokens using "https://mynetbox/api/users/tokens/", but I get the following error:
{"detail":"Authentication credentials were not provided."}
The syntax that I used is:
token = requests.get("https://mynetbox/api/users/tokens/", data={"username": <username>, "password": <password>})
If I am logged in UI with the same username and password in Netbox and access that link, I get the results. Any hints of what's wrong would be highly appreciated.
Netbox version that I am using is v3.3.5.
Thank you!
—
Reply to this email directly, view it on GitHub<#10796>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UMYKOYP5RVDDPJEIC43WF7GWVANCNFSM6AAAAAARTDP4UU>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Use Update: and you need to use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to get the already created tokens using "https://mynetbox/api/users/tokens/", but I get the following error:
{"detail":"Authentication credentials were not provided."}
The syntax that I used is:
token = requests.get("https://mynetbox/api/users/tokens/", data={"username": <username>, "password": <password>})
If I am logged in UI with the same username and password in Netbox and access that link, I get the results. Any hints of what's wrong would be highly appreciated.
Netbox version that I am using is v3.3.5.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions