# Http request Method put "Unauthorized"

**URL:** https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107
**Category:** General
**Tags:** http-request
**Created:** [17 October 2023 11:55 UTC](https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107 "2023-10-17T11:55:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![fabio.amorim](https://avatars.discourse-cdn.com/v4/letter/f/aca169/32.png) [@fabio.amorim](https://discourse.nodered.org/u/fabio.amorim)
#### Post date: [17 October 2023 11:55 UTC](https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107/1 "2023-10-17T11:55:58Z")

</div>

"I'm using the HTTP request to write flows in Node-RED from a repository, it was working perfectly until I enabled adminAuth. After enabling it, I receive the following message 'Unauthorized.' I've tried using basic, digest, and bearer authentication with the username and password I use for logging into Node-RED, but it doesn't work. The issue is not with fetching from the repository as I can retrieve the JSON exactly; the problem is specifically with the PUT request. Does anyone have any ideas on how to resolve this? I need to have adminAuth."

 ![Captura de tela 2023-10-17 085147](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6a3420ebf8f0ae5c7c98ffb12f9cfce90317e6b9.png)

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [17 October 2023 12:06 UTC](https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107/2 "2023-10-17T12:06:51Z")

</div>

Hi @fabio.amorim

The Admin API uses token based authentication, therefore you need to have a token before hand.

You obtain an `access_token` with a call to the `auth` API.

See below  
[POST /auth/token : Node-RED (nodered.org)](https://nodered.org/docs/api/admin/methods/post/auth/token/)

Once you have a token, you can then use that with the request node set to `bearer authentication`

---

<div class="post-metadata">

### Author: ![fabio.amorim](https://avatars.discourse-cdn.com/v4/letter/f/aca169/32.png) [@fabio.amorim](https://discourse.nodered.org/u/fabio.amorim)
#### Post date: [17 October 2023 13:20 UTC](https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107/3 "2023-10-17T13:20:49Z")

</div>

Hi @marcus-j-davies

I was able to obtain the token, and I would like to know if it's possible to modify its expiration time.

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [17 October 2023 13:28 UTC](https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107/4 "2023-10-17T13:28:41Z")

</div>

Add this to `adminAuth`

```auto
adminAuth: {
    sessionExpiryTime: XXXXXX, /* Seconds */
    ...
}

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [31 October 2023 13:28 UTC](https://discourse.nodered.org/t/http-request-method-put-unauthorized/82107/5 "2023-10-31T13:28:56Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
