Using --insecure to test features

109 views
Skip to first unread message

Stephen Christenson

unread,
Aug 12, 2020, 3:03:11 PM8/12/20
to NetBox
All,

Can anyone provide me with some direction

I am having issues when trying to POST using Postman or cURL.  I have also tried the cURL command on the server itself and get the following messages

without a Token:
"detail":"Authentication credentials were not provided."

with the Token:
"detail":"You do not have permission to perform this action."

Only relatable issue I can find is with the LOGIN_REQUIRED optional flag.  This is False.

I am running the instance from the command prompt with the --insecure flag.  I can GET any info I want and I can add/create from within the API GUI, but not from any external source.  Is this because of the --insecure flag possibly?


Brian Candler

unread,
Aug 12, 2020, 4:26:36 PM8/12/20
to NetBox
https://netbox.readthedocs.io/en/stable/api/authentication/

If you have provided a token, then perhaps the user you have assigned it to doesn't have rights to perform the action you're requesting.  To test this, try setting the "superuser" flag on that user.  If that solves the problem, then you can assign more specific rights to the user or group as required.

The --insecure flag is unrelated to the API:

Stephen Christenson

unread,
Aug 12, 2020, 4:56:59 PM8/12/20
to Brian Candler, NetBox
Brian,

Thanks for the reply.  I did review the authentication documentation before submitting the request.  I only have one user currently configured on this test server.  That user currently has Super User and Staff rights and is active. 

It may be I am doing something wrong with the authentication process.  I am relatively new to Rest API.  Do I also need to add basic auth with the username and password in the authentication besides the Token key?  I think I tried that as well already in Postman, but got the same error messages.

Any other ideas I can check? 


--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/7e4e3182-3962-4c38-b67e-ee0a9ea67cbco%40googlegroups.com.

Brian Candler

unread,
Aug 13, 2020, 3:40:08 AM8/13/20
to NetBox
No basic auth required, just the token.  It worked with token first time for me, with curl and pynetbox.

At /admin/users/token/ in the GUI, check the token is write-enabled and does not expire:


Check the format of the Authorization header - it must contain the word "Token" followed by a space and the token.  Try the following, replacing xxxxxxxx with valid token:

curl -Ss -H "Authorization: Token xxxxxxxx" -X OPTIONS http://netbox.example.net/api/dcim/interfaces/ | python3 -m json.tool

On my machine if I remove the authorization header, I get a small response:

$ curl -Ss -X OPTIONS http://netbox.example.net/api/dcim/interfaces/ | python3 -m json.tool
{
    "name": "Interface",
    "description": "",
    "renders": [
        "application/json",
        "text/html"
    ],
    "parses": [
        "application/json",
        "application/x-www-form-urlencoded",
        "multipart/form-data"
    ]
}

With a valid authorization header I get a much longer response including all the field options.  If I include "Authorization: Token xxx" where xxx is not a valid token, I get

{
    "detail": "Invalid token"
}

The other question is, what's the exact POST you are trying to do?  It may be that's invalid.

Stephen Christenson

unread,
Aug 13, 2020, 12:32:34 PM8/13/20
to Brian Candler, NetBox
Thanks Brian,

Appreciate the full and detailed response.  Turned out being the first thing you provided.  The token was not "write enabled".  Sorry for any trouble.  Should have read things closer.  I saw the red ex even, just didn't register in my brain what it was.  Things are working as expected now.

UNLV Logo

Steve Christenson
Network Engineer
OIT - Network Development and Engineering
University of Nevada, Las Vegas

steve.ch...@unlv.edu
Office: 702-895-0784

unlv.edu  Twitter  Facebook  Instagram  YouTube



--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages