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

curl syntax to verify application token #652

Closed cmonty14 closed 6 months ago

cmonty14 commented 6 months ago

Have you read the documentation?

You are setting up gotify in

Describe your problem I have defined an application in Gotify. How can I verify using curl syntax if the token is working correctly fetching data via API?

Any errors, logs, or other information that might help us identify your problem Running this command curl -L -k -H 'X-Gotify-Key:ASaG-yml6So3yx-' http://gotify.example.com:8680/client or curl -L -k "http://gotify.example.com:8680/client?token=ASaG-yml6So3yx-" fails with error: {"error":"Unauthorized","errorCode":401,"errorDescription":"you need to provide a valid access token or user credentials to access this api"}

jmattheis commented 6 months ago

Application are only allowed to POST to /message, any other api gives 401. You can do this request:

$ curl -X POST 'http://localhost:8080/message' -H 'Authorization: bearer ACZPatHGzL-z3i9'

if it returns 401 the token is invalid, if it's 400 it's a valid token.

cmonty14 commented 6 months ago

Running this command curl -X POST "http://gotify.example.com:8680/message?token=ASaG-yml6So3yx-" -F "title=notification" -F "message=message from terminal" is working as expected: {"id":2,"appid":3,"message":"message from terminal","title":"notification","priority":1,"date":"2024-05-14T14:59:10.475177001+02:00"}

jmattheis commented 6 months ago

Okay, then there is no problem anymore?