#community-help

Issue with Accessing Metrics and Aliases in UI with RO Key

TLDR James faced a 401 error while accessing metrics and aliases with a Read-Only key. Kishore Nallan suggested using 'metrics.json:list' and 'aliases:list' actions to fix the issue; this solution worked.

Powered by Struct AI
+11
9
22mo
Solved
Join the chat
Nov 12, 2021 (22 months ago)
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
08:56 PM
I'm creating a small read-only UI to view stats, collections, aliases, etc. As such I created a RO key with these parameters:
print(client.keys.create({
    "description": "Search and RO access key.",
    "actions": ["documents:search","metrics:get","aliases:get"],
    "collections": ["*"],
}))

The resultant key allows me to search across my collections, however, for metrics and aliases I'm getting a 401 with that key. Thought I scoped this correctly, but clearly I did not.
Nov 13, 2021 (22 months ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:49 AM
Kishore Nallan ^
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:40 AM
Let me check on this and get back to you. What version of Typesense are you using?
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
03:56 AM
I'm on version 0.21.0
03:56
James
03:56 AM
Thanks!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:52 AM
James The actions must be metrics.json:list and aliases:list because those are listing end-points. Metrics requires .json suffix since we could support other formats in future.

To allow access to individual aliases (e.g. /aliases/foo), you need aliases:get permission.
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
04:50 PM
Got it. Thank you, I will make those changes.
+11
Nov 16, 2021 (22 months ago)
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
06:57 PM
This worked, BTW. Thank you very much!
Nov 17, 2021 (22 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:56 AM
Welcome!