#community-help

Scoping API Key for All Permissions & Searches

TLDR James requests help to scope an API key for all searches and permissions. Jason suggests adding aliases:get and metrics:get. This suggestion doesn't resolve the issue; the thread is marked as unresolved.

Powered by Struct AI
Sep 15, 2021 (26 months ago)
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
05:30 PM
Hello. How would I scope an api key to allow searches on all collections AND permissions to list the collections, aliases and get metrics? I have this for search "actions": ["documents:search"], "collections": ["*"], which works, but the others permissions I'm unsure about.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:56 PM
Could you try aliases:get and metrics:get?
Sep 16, 2021 (26 months ago)
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
09:59 PM
I tried that and I still get a "Forbidden" for the key:
^_^[james@ganymede:~]$ export TS_ADM_KEY=<REDACTED>
^_^[james@ganymede:~]$ curl '' \
> -X POST \
> -H "X-TYPESENSE-API-KEY: ${TS_ADM_KEY}" \
> -H 'Content-Type: application/json' \
> -d '{"description": "Minimal UI key", "actions": ["documents:search","metrics:get","aliases:get"], "collections": ["*"]}'
{"actions":["documents:search","metrics:get","aliases:get"],"collections":["*"],"description":"Minimal UI key","expires_at":64723363199,"id":4,"value":"<MIN_API_KEY>"}

^_^[james@ganymede:~]$
^_^[james@ganymede:~]$
^_^[james@ganymede:~]$ export MIN_API_KEY=<MIN_API_KEY>
^_^[james@ganymede:~]$ curl '' \
> -H "X-TYPESENSE-API-KEY: ${MIN_API_KEY}"
{"message": "Forbidden - a valid `x-typesense-api-key` header must be sent."}^_^[james@ganymede:~]$
^_^[james@ganymede:~]$
^_^[james@ganymede:~]$ curl '' -H "X-TYPESENSE-API-KEY: ${MIN_API_KEY}"
{"message": "Forbidden - a valid `x-typesense-api-key` header must be sent."}
^_^[james@ganymede:~]$
10:01
James
10:01 PM
does work with admin key (as you would expect):
^_^[james@ganymede:~]$ curl '' -H "X-TYPESENSE-API-KEY: ${TS_ADM_KEY}"
{"aliases":[{"collection_name":"scimago-20210913","name":"scimago"},{"collection_name":"search-20210913","name":"search"},{"collection_name":"openurl-20210914","name":"openurl"},{"collection_name":"browse-20210913","name":"browse"},{"collection_name":"content-20210913","name":"content"}]}
^_^[james@ganymede:~]$ curl '' -H "X-TYPESENSE-API-KEY: ${TS_ADM_KEY}"
{
  "system_cpu1_active_percentage": "0.00",
  "system_cpu_active_percentage": "0.00",
  "system_disk_total_bytes": "25832407040",
  "system_disk_used_bytes": "4128784384",
  "system_memory_total_bytes": "1028968448",
  "system_memory_used_bytes": "479678464",
  "system_network_received_bytes": "1465995489",
  "system_network_sent_bytes": "256701323",
  "typesense_memory_active_bytes": "178778112",
  "typesense_memory_allocated_bytes": "173139992",
  "typesense_memory_fragmentation_ratio": "0.03",
  "typesense_memory_mapped_bytes": "193572864",
  "typesense_memory_metadata_bytes": "8894784",
  "typesense_memory_resident_bytes": "178778112",
  "typesense_memory_retained_bytes": "198070272"
}
^_^[james@ganymede:~]$
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:01 PM
Kishore Nallan ^