immanuelfodor / matrix-encrypted-webhooks

Send any JSON and form data through webhooks to Matrix end-to-end encrypted (E2EE) rooms with HTTP POST requests
MIT License
17 stars 5 forks source link

Secret Token #4

Closed RobertDWhite closed 2 years ago

RobertDWhite commented 2 years ago

Hello, I have the service running, but I am not able to send an HTTP POST to the server. How/where do you obtain the SECRETTOKEN required for post?

RobertDWhite commented 2 years ago

Nevermind. I think I found the solution in another comment. Posting for visibility from repo maintainer.

Update: Here is a guide how to obtain it properly: https://t2bot.io/docs/access_tokens/

When setting up bots, it is common for the bot to require an "access token" in order to work. Access tokens authenticate bots to the server so that they can function. Access tokens should be kept secret and never shared.

In a private/incognito browser window, open Element.
Log in to the account you want to get the access token for, such as the bot's account.
Click on the bot's name in the top left corner then "Settings".
(Optional) Set your bot's display name and avatar.
Click the "Help & About" tab (left side of the dialog).
Scroll to the bottom and click the <click to reveal> part of Access Token: <click to reveal>.
Copy your access token to a safe place, like the bot's configuration file.
Do not log out. Instead, just close the window. If you used a private browsing session, you should be able to still use Element for your own account. Logging out deletes the access token from the server, making the bot unable to use it.
RobertDWhite commented 2 years ago

So, after obtaining the secret token, when attempting to POST to the server with http://localhost:8000/post/secrettoken, I am getting a 404 192 error in the logs.

immanuelfodor commented 2 years ago

Nope, that's not it, these two are completely different things. The SECTETTOKEN can be an arbitrary but long string (like openssl rand -hex 16) which you need to add to the config to let the bot know the association between the token and the corresponding room/notification source name. More info here: https://github.com/immanuelfodor/matrix-encrypted-webhooks#the-notification-channels