Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

REST - Token utilization

Hi.

In my API tests, while not using a browser, which asks authentication, I am trying to authenticate directly on my code. I am sending the follow POST request:

POST https://10.0.0.1/mgmt/shared/authn/login

{
"username": "admin",
"password": "myStrongPasswd",
"loginProviderName": "tmos"
}

I receive the token in the response, as follow:

"token": {
    "token": "MY_26_LENGTH_TOKEN",
    "name": "MY_26_LENGTH_TOKEN",
    "userName": "admin",
    "authProviderName": "tmos",

I can't see any errors in the response, so everything looks fine. After that, I try to send new requests using the token, as follow:

GET https://10.0.0.1/mgmt/tm/asm/signature-sets

{
"X-F5-Auth-Token": "MY_26_LENGTH_TOKEN"
}

But I receive as the response a message saying that I am not authenticated.

<h1>Authentication required!</h1>
<p>
    This server could not verify that you are authorized to access
    the URL "/mgmt/tm/asm/signature-sets".
    You either supplied the wrong credentials (e.g., bad password), or your
    browser doesn't understand how to supply the credentials required.

What I am doing wrong in this case?

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Are you sending the token as a header?

For example:

curl -X GET -H "X-F5-Auth-Token: ABCDEFGHIJKLMNOPQRSTUVWXYZ" "https://10.0.0.1/mgmt/tm/asm/signature-sets"

0
Comments on this Answer
Comment made 1 week ago by rpuga 59

Basically this was the issue. I wasn't sending as a header :)

GET https://10.0.0.1/mgmt/tm/asm/signature-sets
X-F5-Auth-Token: MY_26_LENGTH_TOKEN

Thank you.

0
Comment made 1 week ago by Lee Sutcliffe 2459

Pleased you got it working :)

0