gotify / server

A simple server for sending and receiving messages in real-time per WebSocket. (Includes a sleek web-ui)
https://gotify.net
Other
11.53k stars 641 forks source link

Creating user specific applications and clients through the api #657

Closed mschipperheyn closed 6 months ago

mschipperheyn commented 6 months ago

Have you read the documentation?

You are setting up gotify in

Describe your problem My objective is to use Gotify in a multi tenant system where each tenant needs to has its own sandbox of a single application and client and a stream for the website with only messages for that tenant

From the discussions here and here, I now understand that applications and client are scoped to a user. So, creating a user and then creating apps and clients with that user would be the ticket. However, I have to do all of this using the api. And I don't see an obvious way to create a user and then create an application and client as that user.

Is there a way to do this?

jmattheis commented 6 months ago

Have you seen the APIs listed here? https://gotify.net/api-docs

mschipperheyn commented 6 months ago

I have. I can see how I can create an app, a user, a client and a message. But how do I create a user and then an app as that user just by using the API? I don't see a way to authenticate as the created user through the api? Perhaps I'm missing something. But I'm looking to do all this with zero use of the UI

jmattheis commented 6 months ago

Create a new user with name and pass, and then use the name and pass to create the application.

ADMIN_CREDS=admin:admin

NEW_NAME=myuser
NEW_PASS=mypass

curl -u "$ADMIN_CREDS" -F "name=$NEW_NAME" -F "pass=$NEW_PASS" 'http://localhost:8080/user'

APP_TOKEN=$(curl -u "$NEW_NAME:$NEW_PASS" -F 'name=newapp' 'http://localhost:8080/application' | jq -r '.token')

echo created app with token "$APP_TOKEN"