# Not authorized (token) when GET groups via REST API

**URL:** https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443
**Category:** Technical assistance
**Created:** [May 27, 2024, 1:46pm UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443 "2024-05-27T13:46:50Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![fluca1978](https://community.zammad.org/user_avatar/community.zammad.org/fluca1978/32/9236_2.png) [@fluca1978](https://community.zammad.org/u/fluca1978)
#### Post date: [May 27, 2024, 1:46pm UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/1 "2024-05-27T13:46:50Z")

</div>

I’m using Zammad 6.2.0, and I’m trying to get the list of groups via REST API (`/api/v1/groups`), but I have "{“error”:“Not authorized (token)!”,“error\_human”:“Not authorized (token)!”}`.  
The user I’m using to query the Zammad service is listed as _Admin_, _Agent_ and _Customer_.  
All the other main endpoints work well, so I don’t understand what is going wrong.  
Any suggestion about how to fix or how to get a more detailed error?

---

<div class="post-metadata">

### Author: ![MrGeneration](https://community.zammad.org/user_avatar/community.zammad.org/mrgeneration/32/9260_2.png) [@MrGeneration](https://community.zammad.org/u/MrGeneration)
#### Post date: [May 27, 2024, 1:47pm UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/2 "2024-05-27T13:47:41Z")

</div>

You may want to share your payload if you expect help with API stuff. No productive data is required.

---

<div class="post-metadata">

### Author: ![fluca1978](https://community.zammad.org/user_avatar/community.zammad.org/fluca1978/32/9236_2.png) [@fluca1978](https://community.zammad.org/u/fluca1978)
#### Post date: [May 27, 2024, 1:55pm UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/3 "2024-05-27T13:55:34Z")

</div>

Here is an example:

```auto
% curl --header "Content-Type: application/json" \
     --header "Authorization: Token token=xxxxxxx" \
  --request GET \
 http://localhost:8080/api/v1/groups
{"error":"Not authorized (token)!","error_human":"Not authorized (token)!"}

```

---

<div class="post-metadata">

### Author: ![fliebe92](https://community.zammad.org/user_avatar/community.zammad.org/fliebe92/32/12102_2.png) [@fliebe92](https://community.zammad.org/u/fliebe92)
#### Post date: [May 27, 2024, 6:33pm UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/4 "2024-05-27T18:33:42Z")

</div>

Hi @fluca1978. Please make sure that `admin.group` permission is associated with the created token, otherwise you’re faced with this error message.

---

<div class="post-metadata">

### Author: ![fluca1978](https://community.zammad.org/user_avatar/community.zammad.org/fluca1978/32/9236_2.png) [@fluca1978](https://community.zammad.org/u/fluca1978)
#### Post date: [May 28, 2024, 7:00am UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/5 "2024-05-28T07:00:32Z")

</div>

Thanks @fliebe92 , I’ve already associated the user with the role permission, but apparently this does not work.  
Regenrating the token, as in:

```auto
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ "name": "perl@test", "permission": ["cti.agent","ticket.agent", "admin.group"], "expires_at": "2024-12-21" }' \
  -u luca.ferrari3@me:XXXXXXX http://localhost:8080/api/v1/user_access_token

```

worked. Is there a way to add a permission without having to re-generate a token?  
Why associating the user to the role/permission from the web interface does not work for the token?

---

<div class="post-metadata">

### Author: ![fliebe92](https://community.zammad.org/user_avatar/community.zammad.org/fliebe92/32/12102_2.png) [@fliebe92](https://community.zammad.org/u/fliebe92)
#### Post date: [May 28, 2024, 8:06am UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/6 "2024-05-28T08:06:28Z")

</div>

Hi @fluca1978.

I just used the GUI to create an access token that has `admin.group` permission set

![image](https://community.zammad.org/uploads/default/original/2X/4/43f15b348e08f382b0a988a3e28c159058830568.png)

and used it with `curl` as follows:

```auto
curl --location 'http://localhost:3000/api/v1/groups' --header 'Content-Type: application/json' --header 'Authorization: Bearer xxx'

```

Works fine.

---

<div class="post-metadata">

### Author: ![system](https://community.zammad.org/uploads/default/original/1X/5c5afaea2d23f811dbec33cd4edb02fa29d3262f.png) [@system](https://community.zammad.org/u/system)
#### Post date: [June 4, 2024, 8:07am UTC](https://community.zammad.org/t/not-authorized-token-when-get-groups-via-rest-api/14443/7 "2024-06-04T08:07:22Z")

</div>

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