api token page - unable to see generated token key after creation (if no key supplied) #8447

Closed
opened 2025-12-29 20:36:51 +01:00 by adam · 3 comments
Owner

Originally created by @ITJamie on GitHub (Aug 10, 2023).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.6-beta1

Python version

3.10

Steps to Reproduce

goto admin > api tokens > add api token
select a user,
do not fill in the key field (key will be autogenerated)
after creation there is no way to see/copy the generated key

Expected Behavior

the generated key should be visible after creation
also maybe admins should be able to view full keys?

Observed Behavior

unable to copy / see the generated API key

Originally created by @ITJamie on GitHub (Aug 10, 2023). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.6-beta1 ### Python version 3.10 ### Steps to Reproduce goto admin > api tokens > add api token select a user, do not fill in the key field (key will be autogenerated) after creation there is no way to see/copy the generated key ### Expected Behavior the generated key should be visible after creation also maybe admins should be able to view full keys? ### Observed Behavior unable to copy / see the generated API key
adam added the type: bugstatus: acceptedbeta labels 2025-12-29 20:36:51 +01:00
adam closed this issue 2025-12-29 20:36:51 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 10, 2023):

@jsenecal suggested reworking the forms a bit so that the token value is generated when the form is rendered, providing the user an opportunity to record it prior to creating the token in the database. I really like this approach because it obviates the need to introduce any complex logic in the views, which now utilize the generic ObjectEditView.

@jeremystretch commented on GitHub (Aug 10, 2023): @jsenecal suggested reworking the forms a bit so that the token value is generated when the form is rendered, providing the user an opportunity to record it _prior_ to creating the token in the database. I really like this approach because it obviates the need to introduce any complex logic in the views, which now utilize the generic ObjectEditView.
Author
Owner

@ITJamie commented on GitHub (Aug 10, 2023):

so the field would be prefilled and new validation to require a value to be supplied (and potentially make sure it has a minimum amount of characters and isn't something silly like "password")?

@ITJamie commented on GitHub (Aug 10, 2023): so the field would be prefilled and new validation to require a value to be supplied (and potentially make sure it has a minimum amount of characters and isn't something silly like "password")?
Author
Owner

@jeremystretch commented on GitHub (Aug 10, 2023):

It means the form field will be pre-populated with a randomly-generated key. No changes to validation are needed, other than the field now being marked as required.

@jeremystretch commented on GitHub (Aug 10, 2023): It means the form field will be pre-populated with a randomly-generated key. No changes to validation are needed, other than the field now being marked as required.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8447