Incorrect Authorization Header included in swagger curl Examples #3418

Closed
opened 2025-12-29 18:28:55 +01:00 by adam · 7 comments
Owner

Originally created by @dstarner on GitHub (Feb 26, 2020).

Environment

  • Python version: 3.7
  • NetBox version: 2.7.8

Observed Behavior

NetBox's Swagger documentation does not include the Token prefix in the Authorization header. This makes it misleading of how to connect correctly to the API. The picture below is old, please see @kobayashi 's screenshot below.

Screen Shot 2020-02-26 at 2 45 44 PM

Expected Behavior

I should be able to copy and paste a curl command (almost) and dump it into into a terminal for it to work. I would like to see something like -H "Authorization: Token $NETBOX_TOKEN" so that I could use it as a valid example.

Originally created by @dstarner on GitHub (Feb 26, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.7 * NetBox version: 2.7.8 <!-- What happened instead? --> ### Observed Behavior NetBox's Swagger documentation does not include the `Token` prefix in the `Authorization` header. This makes it misleading of how to connect correctly to the API. The picture below is old, please see @kobayashi 's screenshot below. ![Screen Shot 2020-02-26 at 2 45 44 PM](https://user-images.githubusercontent.com/10478871/75381411-af795000-58a6-11ea-82a4-94fea65be8d8.png) <!-- What did you expect to happen? --> ### Expected Behavior I should be able to copy and paste a `curl` command (almost) and dump it into into a terminal for it to work. I would like to see something like `-H "Authorization: Token $NETBOX_TOKEN"` so that I could use it as a valid example.
adam added the type: documentationstatus: needs owner labels 2025-12-29 18:28:55 +01:00
adam closed this issue 2025-12-29 18:28:56 +01:00
Author
Owner

@kobayashi commented on GitHub (Feb 28, 2020):

You can see it after you set apikey through "Authorized" button which is placed right side of top.

Screenshot from 2020-02-28 00-06-06

@kobayashi commented on GitHub (Feb 28, 2020): You can see it after you set apikey through "Authorized" button which is placed right side of top. ![Screenshot from 2020-02-28 00-06-06](https://user-images.githubusercontent.com/8712070/75512037-28b79680-59be-11ea-963f-2990b7aeaeeb.png)
Author
Owner

@dennisgove commented on GitHub (Feb 28, 2020):

Yes, that header information is displayed. However, the actual header that needs to be sent in is Authorization: Token <actual token>. The Token prefix before the actual token doesn't appear in this header.

@dennisgove commented on GitHub (Feb 28, 2020): Yes, that header information is displayed. However, the actual header that needs to be sent in is `Authorization: Token <actual token>`. The `Token ` prefix before the actual token doesn't appear in this header.
Author
Owner

@jeremystretch commented on GitHub (Feb 28, 2020):

Open for volunteers.

@jeremystretch commented on GitHub (Feb 28, 2020): Open for volunteers.
Author
Owner

@kobayashi commented on GitHub (Mar 2, 2020):

Ah, sorry I miss understood this issue. Token prefix before the value could not be in OPENAPI Spec v2.0 which is generated in drf-yasg. To make it possible, you have to add the prefix when set your token in authenticate window like Token <token here>. The similar issue was asked here

@kobayashi commented on GitHub (Mar 2, 2020): Ah, sorry I miss understood this issue. `Token ` prefix before the value could not be in OPENAPI Spec v2.0 which is generated in drf-yasg. To make it possible, you have to add the prefix when set your token in authenticate window like `Token <token here>`. The similar issue was asked [here](https://github.com/axnsan12/drf-yasg/issues/46)
Author
Owner

@dstarner commented on GitHub (Mar 2, 2020):

Ah, okay then, interesting. So this is probably something we can close then? Or is there a way we can show it without hacking drf-yasg? It would be helpful since NetBox relies on the Token being there

@dstarner commented on GitHub (Mar 2, 2020): Ah, okay then, interesting. So this is probably something we can close then? Or is there a way we can show it without hacking drf-yasg? It would be helpful since NetBox relies on the `Token ` being there
Author
Owner

@kobayashi commented on GitHub (Mar 3, 2020):

I would like to avoid to add some hacking way for this because it might leads not follow the spec version. Or, it will be difficult maintain and upgrade drf-yasg in the future.
If the purpose of this issue is to copy & paste, we can do it even though a little tricky 😛
BTY, I think we can set the value after drf-yasg will supports openapi spec v3.0 probably.

@kobayashi commented on GitHub (Mar 3, 2020): I would like to avoid to add some hacking way for this because it might leads not follow the spec version. Or, it will be difficult maintain and upgrade drf-yasg in the future. If the purpose of this issue is to copy & paste, we can do it even though a little tricky :stuck_out_tongue: BTY, I think we can set the value after drf-yasg will supports openapi spec v3.0 probably.
Author
Owner

@kobayashi commented on GitHub (Mar 3, 2020):

Close this because openapi spec v2.0 (current drf-yasg supported) is not supported to show Token prefix in curl example.

@kobayashi commented on GitHub (Mar 3, 2020): Close this because openapi spec v2.0 (current drf-yasg supported) is not supported to show `Token` prefix in curl example.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3418