# Kibana Rest API redirects to login

**URL:** <https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799>\
**Category:** Kibana\
**Created:** [November 26, 2020, 4:47pm UTC](https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799 "2020-11-26T16:47:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ludo\_Vic](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@Ludo\_Vic](https://discuss.elastic.co/u/Ludo_Vic)\
**Post date:** [November 26, 2020, 4:47pm UTC](https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799/1 "2020-11-26T16:47:25Z")

</div>

Hi,

I'm new to ElasticSearch and Kibana. I'm trying to use Kibana's REST API, but the response i get are redirections to /login whatever the request i try.

For example :

```
$ curl -v -u user:passwd -X GET "127.0.0.1:5601/demo/api/features"

* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 5601 (#0)
* Server auth using Basic with user 'user'
> GET /demo/api/features HTTP/1.1
> Authorization: Basic xxxxxxxx
> User-Agent: curl/7.38.0
> Host: 127.0.0.1:5601
> Accept: */*
>
< HTTP/1.1 302 Found
< location: /demo/login?nextUrl=/demo/api/features
< kbn-name: kibana
< content-type: text/html; charset=utf-8
< cache-control: no-cache
< content-length: 0
< connection: close
< Date: Thu, 26 Nov 2020 10:32:56 GMT
<
* Closing connection 0

```

I'm using v7.2.0 with Linux.

Could someone tell me what i'm doing wrong ?

Best regards,  
Ludo

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [November 26, 2020, 4:59pm UTC](https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799/2 "2020-11-26T16:59:16Z")

</div>

Hi  
is kibana configured with a different basePath `/demo` ?

---

<div class="post-metadata">

**Author:** ![Ludo\_Vic](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@Ludo\_Vic](https://discuss.elastic.co/u/Ludo_Vic)\
**Post date:** [November 26, 2020, 5:11pm UTC](https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799/3 "2020-11-26T17:11:12Z")

</div>

Yes. And rewriteBasePath is set to True.

---

<div class="post-metadata">

**Author:** ![Ludo\_Vic](https://avatars.discourse-cdn.com/v4/letter/l/9de0a6/32.png) [@Ludo\_Vic](https://discuss.elastic.co/u/Ludo_Vic)\
**Post date:** [December 2, 2020, 3:37pm UTC](https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799/4 "2020-12-02T15:37:54Z")

</div>

The problem came from the use of the plugin readonlyrest.  
I need to first log in, and retrieve the cookie, before querying for anything :

```auto
curl -v -X POST "127.0.0.1:5601/demo/login" -d "username=user&password=passwd"-H "kbn-xsrf: true" -H 'Accept: application/json' -c cookie.txt

```

And then use the cookie :

```auto
curl -v -X GET "127.0.0.1:5601/demo/api/features" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -H "Accept: application/json" -b cookie.txt

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 30, 2020, 3:38pm UTC](https://discuss.elastic.co/t/kibana-rest-api-redirects-to-login/256799/5 "2020-12-30T15:38:10Z")

</div>

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