# API Authorization error

**URL:** <https://community.graylog.org/t/api-authorization-error/3336>\
**Category:** Graylog Central (peer support)\
**Created:** [November 29, 2017, 6:28pm UTC](https://community.graylog.org/t/api-authorization-error/3336 "2017-11-29T18:28:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mantil](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Mantil](https://community.graylog.org/u/Mantil)\
**Post date:** [November 29, 2017, 6:28pm UTC](https://community.graylog.org/t/api-authorization-error/3336/1 "2017-11-29T18:28:18Z")

</div>

I have a call that goes something like this.

```
https://x.x.x.x:12900/api/search/universal/relative/terms?field=cs-user-agent&query=*&size=250&range=86400

```

When doing this from my admin account I have no problems but as soon as I try from any non admin account I get this message.

```
 {"type":"ApiError","message":"Not authorized"}

```

What can I do to work around this. I’m not seeing an “All” messages option in authentication to allow a non admin user or role to run this query.

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [November 30, 2017, 8:18am UTC](https://community.graylog.org/t/api-authorization-error/3336/2 "2017-11-30T08:18:12Z")

</div>

I’d recommend creating a stream for that specific purpose and allow the non-admin account to access that stream.

If you absolutely want the non-admin account to have access to the universal search (which I wouldn’t recommend), you have to create a role with the permissions `searches:absolute`, `searches:keyword`, or `searches:relative` (depending on what type of search you want to execute).

See [http://docs.graylog.org/en/2.3/pages/users\_and\_roles.html](http://docs.graylog.org/en/2.3/pages/users_and_roles.html) for details.

---

<div class="post-metadata">

**Author:** ![Mantil](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Mantil](https://community.graylog.org/u/Mantil)\
**Post date:** [November 30, 2017, 4:09pm UTC](https://community.graylog.org/t/api-authorization-error/3336/3 "2017-11-30T16:09:24Z")

</div>

I applied your first recommendation by creating a stream with a rule that uses “message” as the field with type “field presence” that seems to match the all messages stream. Seems to work from what I see. Would you recommend another route as far as the stream setup. While this works I may be missing a more obvious/efficient method.

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [November 30, 2017, 4:10pm UTC](https://community.graylog.org/t/api-authorization-error/3336/4 "2017-11-30T16:10:59Z")

</div>

Why not check for the presence of the “cs-user-agent” field you’ve mentioned in your first post?

Also, if you’re matching _every_ message, you could simply allow access to the default stream (which already contains all messages).

---

<div class="post-metadata">

**Author:** ![Mantil](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Mantil](https://community.graylog.org/u/Mantil)\
**Post date:** [November 30, 2017, 4:19pm UTC](https://community.graylog.org/t/api-authorization-error/3336/5 "2017-11-30T16:19:51Z")

</div>

That was just an example. That field could easily change based on the data we are trying to pull out. I think I can make this work with your current recommendations. But at the most basic level we were looking to create a single user/role to be able to make those universal queries but not have access to any other admin level access so they couldn’t view or make any changes to any “system” options (authentication,configurations,indices, etc.)in the interface or via API.

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [November 30, 2017, 4:43pm UTC](https://community.graylog.org/t/api-authorization-error/3336/6 "2017-11-30T16:43:49Z")

</div>

As I said before, you can allow the account access to the “All messages" stream.

---

<div class="post-metadata">

**Author:** ![Mantil](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Mantil](https://community.graylog.org/u/Mantil)\
**Post date:** [November 30, 2017, 5:03pm UTC](https://community.graylog.org/t/api-authorization-error/3336/8 "2017-11-30T17:03:54Z")

</div>

Last post withdrawn. Looks as though that didn’t work. I allowed access to “all messages stream” in fact it was already enabled. But still retaining that error when querying that stream for in this case the “user-agent” field.

---

<div class="post-metadata">

**Author:** ![Mantil](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Mantil](https://community.graylog.org/u/Mantil)\
**Post date:** [November 30, 2017, 5:10pm UTC](https://community.graylog.org/t/api-authorization-error/3336/9 "2017-11-30T17:10:21Z")

</div>

for the role. Here is a screenshot of that being allowed. BTW this role has ALL streams allowed for both viewing and editing at the moment. This isn’t just a problem for all messages but any stream I try to query as a non admin user. Even though all streams are allowed for users in this role that query regardless of stream will get that auth error.

 ![roles](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/2X/5/5600f350cc886cb2dcc8ddcd82d9d16e1fd7e45e.jpg)

Am I missing something crazy simple here?

---

<div class="post-metadata">

**Author:** ![Mantil](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Mantil](https://community.graylog.org/u/Mantil)\
**Post date:** [November 30, 2017, 5:22pm UTC](https://community.graylog.org/t/api-authorization-error/3336/10 "2017-11-30T17:22:19Z")

</div>

I got it Jochen. I wasn’t using the filter correctly. Found that Stream:Streamid in the filter works. Thank you for the help on this. Got me down the right path.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [December 14, 2017, 5:22pm UTC](https://community.graylog.org/t/api-authorization-error/3336/11 "2017-12-14T17:22:27Z")

</div>

Closed on December 14, 2017, 5:22pm UTC

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