I am building a snap to access the snapd rest api interface. I want to be able to run my snap as root so that I can by pass the snap store/macroon authentication. Below is the command I am running with its output:
sudo {snap-name} /v2/snapctl post "{\"context-id\":\"ABCDEF\
",\"args\":[\"get\",\"value\"]}"
------------REQUEST--------------
POST /v2/snapctl HTTP/1.1
Host: localhost
Content-Length: 73
Content-Type: application/json
{"context-id":"ABCDEF","args":["get","value"]}
---------------Response------------------
HTTP/1.1 403 Forbidden
date: tue, 07 nov 2023 16:32:52 gmt
content-length: 116
content-type: application/json
{"type":"error","status-code":403,"status":"Forbidden","result":{"message":"access denied","kind":"login-required"}}
From the documentation below it looks like I should be able to just run this as a root user (without signing into the snap store):
https://snapcraft.io/docs/using-the-api#heading–authentication
Do I have to be logged into the snap store for this to work? Or am I doing something wrong?