Thank you for the help @Florent_F! It took me a moment to figure out what you meant by âone the serverâ To make it clear for anyone reading in the future:
you need to rune this command in the command line of your server where $BEARER
is your API key
$ curl -X POST -H "content-type:application/json" -d '{"name": "foo", "domain": "foo"}' -H "Authorization: Bearer $BEARER" http://localhost:8484/api/orgs
Also for future readers: if you are wanting API access to your self hosted instance using yunohost like I was youâll need to modify your nginx config
WARNING you may break your config. Take a backup or be sure you know what you are doing. Also, donât trust code or commands from strangers on the internet without knowing what it does.
In the command line of your server you can navigate to your grist nginx config and start editing using nano by doing.
sudo nano /etc/nginx/conf.d/example.com.conf
Replace example.com
with the hostname of your grist instance.
Add the following to your server block that listens on 443.
location /api {
access_by_lua_block { }
proxy_pass http://localhost:8484; # Replace 8484 with the actual port Grist is running on if its not 8484
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Add the location block above this line found within the server block:
access_by_lua_file /usr/share/ssowat/access.lua;
You can close the file doing ctrl+x and then entering âyâ to save. Test your nginx config to make sure its valid by doing
sudo nginx -t
If the test passes you can reload nginx by doing
sudo systemctl reload nginx
The location /api block will expose all the API endpoints for your yunohost instance. The access_by_lua_block { }
makes it so that anyone on the internet can reach those enpoints without being logged into your yunohost instance. This should be fine as an api token is needed to authenticate into the grist API.
If you happen to be using nodejs client to call the API like I am, your DOC_URL
parameter should be
https://example.com/${documentId}
where example is replaced by your hostname.