Matrix-appservice-irc: need help.. M_UNKNOWN_TOKEN: Invalid macaroon passed

Created on 13 Jan 2020  路  9Comments  路  Source: matrix-org/matrix-appservice-irc

Hello,
i try to install the matrix-appservice-irc for my synapse instance (v 1.8.0).
(creme in #irc:matrix.org)

Notice

sysinfo:

matrix-irc@matrix:~$ cat /etc/debian_version 
10.2
matrix-irc@matrix:~$ nodejs --version
v10.18.1
matrix-irc@matrix:~$ npm --version
6.13.4
  • synapse setup works.. (federationstester)
  • the synapse instance runs on the same machine how the irc-appservice.
  • macaroon_secret_key is deposited in homeserver.yaml
  • privacy policy must be accepted on new registrations

Install Process

create user and login:

adduser --shell /usr/sbin/nologin --disabled-password --home /opt/matrix-appservice-irc matrix-irc
sudo -u matrix-irc bash

Install:

git clone https://github.com/matrix-org/matrix-appservice-irc.git
cd matrix-appservice-irc
npm install
# needs ..
npm audit fix
npm test # PASS!

edit my config.yaml

registration:

node app.js -r -f appservice-registration-irc.yaml -u "http://localhost:9999" -c config.yaml -l IRCBot

created my appservice-registration-irc.yaml (is readable for synapse user)

After this step, I couldn't find a new user for my instance via the api!

token="..."
curl -X GET -H "Authorization: Bearer $token" "https://matrix.envs.net/_synapse/admin/v2/users?deactivated=true"
# no irc_bot listed here..

now i add the appservice to my synapse config and restart the service:

...
app_service_config_file:
  - "/opt/matrix-appservice-irc/appservice-registration-irc.yaml"

...

```bash
systemctl restart matrix-synapse.service

start the appservice:
```bash
node app.js -c config.yaml -f appservice-registration-irc.yaml -p 9999

LOG:

2020-01-12 23:25:35 INFO:DataStore Indexes checked on 'id' for store.
2020-01-12 23:25:35 INFO:DataStore Indexes checked on 'matrix_id' for store.
2020-01-12 23:25:35 INFO:DataStore Indexes checked on 'remote_id' for store.
2020-01-12 23:25:35 INFO:DataStore Indexes checked on 'localpart' for store.
2020-01-12 23:25:35 INFO:DataStore Indexes checked on 'user id' for store.
2020-01-12 23:25:35 INFO:DataStore storeRoom (id=!wLcaYYSPIiDNdDPniR:envs.net, addr=irc.tilde.chat, chan=#envs, origin=config)                                                                                                                
2020-01-12 23:25:35 INFO:DataStore Indexes checked for ident username for irc.tilde.chat on users database
2020-01-12 23:25:35 INFO:IrcBridge Fetching Matrix rooms that are already joined to...
2020-01-12 23:25:35 INFO:IrcBridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) Body:
2020-01-12 23:25:35 ERROR:IrcBridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) HTTP 401 Error: "{\"errcode\":\"M_UNKNOWN_TOKEN\",\"error\":\"Invalid macaroon passed.\",\"soft_logout\":false}"                        
2020-01-12 23:25:35 ERROR:IrcBridge Failed to fetch roomlist from joined_rooms: M_UNKNOWN_TOKEN: Invalid macaroon passed.. Retrying                                                                                                           
2020-01-12 23:25:38 INFO:IrcBridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) Body:
2020-01-12 23:25:38 ERROR:IrcBridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) HTTP 401 Error: "{\"errcode\":\"M_UNKNOWN_TOKEN\",\"error\":\"Invalid macaroon passed.\",\"soft_logout\":false}"                        
2020-01-12 23:25:38 ERROR:IrcBridge Failed to fetch roomlist from joined_rooms: M_UNKNOWN_TOKEN: Invalid macaroon passed.. Retrying
needs-investigation

Most helpful comment

lol i found the problem.. is a very small thing:

...
app_service_config_file:
  - "/opt/matrix-appservice-irc/appservice-registration-irc.yaml"

...

i forget the trailing s

app_service_config_files:

All 9 comments

token="..."
curl -X GET -H "Authorization: Bearer $token" "https://matrix.envs.net/_synapse/admin/v2/users?deactivated=true"
# no irc_bot listed here..

This won't exist, the user is a bridge bot.

2020-01-12 23:25:38 ERROR:IrcBridge Failed to fetch roomlist from joined_rooms: M_UNKNOWN_TOKEN: Invalid macaroon passed.. Retrying

This feels very much like you have either not restarted, restarted the wrong homeserver, or the bridge is not using your registration file.

hmm I can not understand ... Above I described what I did.

I reset the installation today and upgraded it to the new version..
v0.14.1

> install log

$ npm test
.

197 specs, 0 failures
Finished in 5.73 seconds

edit my config.yaml

registration:

node app.js -r -f appservice-registration-irc.yaml -u "http://localhost:9999" -c config.yaml -l IRCBot

add the appservice to my synapse config and restart the service:

# restart
systemctl restart matrix-synapse.service

start the appservice:

node app.js -c config.yaml -f appservice-registration-irc.yaml -p 9999

(node:19986) [DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated.
(node:19986) [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.
(node:19986) [DEP0011] DeprecationWarning: crypto.Credentials is deprecated. Use tls.SecureContext instead.
2020-01-23 09:26:09 ERROR:CLI Failed to run bridge.

thanks for your help

same problem with version 0.15.0 :/

node app.js -r -f appservice-registration-irc.yaml -u "http://localhost:9999" -c config.yaml -l IRC_Bot                                                                                                                  
2020-02-05 18:36:13 ERROR:CLI Failed to generate registration:

I solved this by changing my synapse configuration. The trusted key server defaults to matrix.org. I had to set it to my server. Hope this helps.

2020-01-23 09:26:09 ERROR:CLI Failed to run bridge.

In Version 0.15.1 i don't have anymore the error. ;)

I have switched the trustkey server to my own. unfortunately that did not bring the desired success.

i have the same macaron issue:

matrix-irc@matrix:~$ node app.js -v -c config.yaml -f appservice-registration-irc.yaml -p 9999                                                                                                                                                
2020-02-09 07:49:38 WARN:IrcBridge ircService.databaseUri is a deprecated config option.Please use the database configuration block                                                                                                           
(node:15824) [DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated.
(node:15824) [DEP0010] DeprecationWarning: crypto.createCredentials is deprecated. Use tls.createSecureContext instead.                                                                                                                       
(node:15824) [DEP0011] DeprecationWarning: crypto.Credentials is deprecated. Use tls.SecureContext instead.
2020-02-09 07:49:38 INFO:IrcBridge Using NeDBDataStore for Datastore
2020-02-09 07:49:38 INFO:NeDBDataStore Indexes checked on 'id' for store.
2020-02-09 07:49:38 INFO:NeDBDataStore Indexes checked on 'matrix_id' for store.
2020-02-09 07:49:38 INFO:NeDBDataStore Indexes checked on 'remote_id' for store.
2020-02-09 07:49:38 INFO:NeDBDataStore Indexes checked on 'localpart' for store.
2020-02-09 07:49:38 INFO:NeDBDataStore Indexes checked on 'user id' for store.
2020-02-09 07:49:38 INFO:NeDBDataStore storeRoom (id=!wLcaYYSPIiDNdDPniR:envs.net, addr=irc.tilde.chat, chan=#envs, origin=config)                                                                                                            
2020-02-09 07:49:38 INFO:NeDBDataStore Indexes checked for ident username for irc.tilde.chat on users database
2020-02-09 07:49:38 INFO:IrcBridge Fetching Matrix rooms that are already joined to...
2020-02-09 07:49:38 INFO:IrcBridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) Body:
2020-02-09 07:49:38 ERROR:IrcBridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) HTTP 401 Error: "{\"errcode\":\"M_UNKNOWN_TOKEN\",\"error\":\"Invalid macaroon passed.\",\"soft_logout\":false}"                        
2020-02-09 07:49:38 ERROR:IrcBridge Failed to fetch roomlist from joined_rooms: M_UNKNOWN_TOKEN: Invalid macaroon passed.. Retrying

synapse homerserver log:

2020-02-09 07:49:56,348 - synapse.api.auth - 373 - WARNING - GET-1141 - Invalid macaroon in auth: <class 'synapse.api.auth._InvalidMacaroonException'>                                                                                        
2020-02-09 07:49:56,348 - synapse.http.server - 81 - INFO - GET-1141 - <XForwardedForRequest at 0x7fb9c80c6978 method='GET' uri='/_matrix/client/r0/joined_rooms?access_token=<redacted>' clientproto='HTTP/1.1' site=8008> SynapseError: 401 - Invalid macaroon passed.

I solved this by changing my synapse configuration. The trusted key server defaults to matrix.org. I had to set it to my server. Hope this helps.

@b1twise do I have to do anything after adding my own server as a trusted one?

trusted_key_servers:
  - server_name: "envs.net"
#  - server_name: "matrix.org"

log:

2020-02-09 14:25:16,949 - synapse.crypto.keyring - 587 - WARNING - GET-45032 - Key lookup failed from 'envs.net': Not retrying server envs.net.

The trusted_key_servers has NOTHING to do with the error here. Please do not change it for this.

To be clear, and hopefully for the last time "Invalid macaroon passed" means you are giving the homeserver a token it does not understand. To be absolutely clear: This means the token (as_token) in your registration yaml file is not one being accepted by your homeserver:

  • You MUST ensure that both the IRC bridge and your homeserver are reading from the same file.
  • You MUST ensure that the homeserver and the bridge have been restarted if this has changed.

If you are absolutely sure you have done these steps and the same error comes up, create an issue on https://github.com/matrix-org/synapse.

lol i found the problem.. is a very small thing:

...
app_service_config_file:
  - "/opt/matrix-appservice-irc/appservice-registration-irc.yaml"

...

i forget the trailing s

app_service_config_files:

Was this page helpful?
0 / 5 - 0 ratings