matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
465 stars 150 forks source link

M_UNKNOWN_TOKEN - Invalid Access Token Passed #1696

Closed ajohns92a closed 1 year ago

ajohns92a commented 1 year ago

Hi! I have reviewed the ticket that closely matches mine: https://github.com/matrix-org/matrix-appservice-irc/issues/942

However I'm still unable to resolve.

2023-04-06 08:31:41 INFO:IrcBridge Using PgDataStore for Datastore
2023-04-06 08:31:41 INFO:CryptoStore Private key loaded from passkey.pem - IRC password encryption enabled.
2023-04-06 08:31:41 INFO:PgDatastore Starting postgres database engine
2023-04-06 08:31:41 INFO:PgDatastore Database schema is at version v8
2023-04-06 08:31:41 INFO:IrcBridge Restoring last active times from DB
2023-04-06 08:31:41 INFO:IrcBridge Restored 0 last active times from DB
2023-04-06 08:31:41 INFO:IrcServer Reconfiguring <irc server redacted>
2023-04-06 08:31:41 INFO:PgDatastore storeRoom (id=!sGaNDNKUXqQzHnqdTe:localhost, addr=<redacted>, chan=#<redacted>, origin=config, type=channel)
2023-04-06 08:31:41 INFO:IrcBridge Listening on 0.0.0.0:9999
2023-04-06 08:31:41 INFO:IrcBridge Started metrics on http://127.0.0.1:7001
Apr-6 08:31:41.890 DEBUG Intent Checking if user @IRCBotz:localhost is registered
Apr-6 08:31:41.898 DEBUG Intent ensureRegistered: already registered
MatrixHttpClient (REQ-1) {
  errcode: 'M_UNKNOWN_TOKEN',
  error: 'Invalid access token passed.',
  soft_logout: false
}
2023-04-06 08:31:41 ERROR:IrcBridge Homeserver cannot reach the bridge. You probably need to adjust your configuration.
2023-04-06 08:31:41 INFO:IrcBridge Fetching Matrix rooms that are already joined to...
MatrixHttpClient (REQ-2) {
  errcode: 'M_UNKNOWN_TOKEN',
  error: 'Invalid access token passed.',
  soft_logout: false
}
2023-04-06 08:31:41 ERROR:IrcBridge Failed to fetch roomlist from joined_rooms: [object Object]. Retrying
MatrixHttpClient (REQ-3) {
  errcode: 'M_UNKNOWN_TOKEN',
  error: 'Invalid access token passed.',
  soft_logout: false

For simplicity - my appservice-registration-irc.yaml file exists in /matrix with full rw permission

hs_token: 398e8933afc147fcbd6da<redacted>
as_token: c0791700b871a19e61aa<redacted>
url: http://localhost:9999
sender_localpart: IRCBotz
de.sorunome.msc2409.push_ephemeral: true
protocols:
  - irc
namespaces:
  rooms:
    - exclusive: false
      regex: '!sGaNDNKUXqQzHnqdTe:localhost'
  aliases:
    - exclusive: true
      regex: '#irc_.*:localhost'
  users:
    - exclusive: true
      regex: '@irc_.*:localhost'
rate_limited: false

homeserver.yaml

listeners:
  - port: 8008
    tls: false
    type: http
    x_forwarded: true
    bind_addresses: ['::1', '127.0.0.1', '192.168.1.53']
    resources:
      - names: [client, federation]
        compress: false
#
database:
  name: psycopg2
  args:
    user: synapse_user
    password: <redacted>
    database: synapse
    host: localhost
    port: 5432
    cp_min: 5
    cp_max: 10
#
enable_registration: true
enable_registration_without_verification: true
registration_shared_secret: "<redacted>"
#
serve_server_wellknown: true
allow_public_rooms_over_federation: true
#
log_config: "/etc/matrix-synapse/log.yaml"
signing_key_path: "/etc/matrix-synapse/homeserver.signing.key"
trusted_key_servers:
  - server_name: "matrix.org"
#Media Retention#
media_retention:
    local_media_lifetime: 36h
    remote_media_lifetime: 36h
#
#History#
retention:
  enabled: true
  default_policy:
    min_lifetime: 6h
    max_lifetime: 35h
  allowed_lifetime_min: 6h
  allowed_lifetime_max: 35h
  purge_jobs:
    - longest_max_lifetime: 35h
      interval: 5m
#    - shortest_max_lifetime: 6h
#      interval: 5h
#URL Preview#
url_preview_enabled: true
#URL Blacklist#
url_preview_ip_range_blacklist:
  - '127.0.0.0/8'
  - '10.0.0.0/8'
  - '172.16.0.0/12'
  - '192.168.0.0/16'
  - '100.64.0.0/10'
  - '192.0.0.0/24'
  - '169.254.0.0/16'
  - '192.88.99.0/24'
  - '198.18.0.0/15'
  - '192.0.2.0/24'
  - '198.51.100.0/24'
  - '203.0.113.0/24'
  - '2001:db8::/32'
  - 'ff00::/8'
  - 'fec0::/10'
#Media Storage#
media_store_path: "/mnt/storage"
#
app_service_config_files: "/matrix/appservice-registration-irc.yaml"

I've not registered any user for the bridge or invited to any room. Should registration occur automatically? Or are there steps I must follow to create a bridge user.

Any guidance would be appreciated! For what it's worth, I administer the target IRC server so I can modify both layers.

OS - Debian 11 Node Version: 18.15.0

ajohns92a commented 1 year ago

I noted the follow error in the Synapse log. After enabling Debugging, there was no further detail.

2023-04-12 03:03:47,132 - synapse.config.appservice - 45 - WARNING - main - Expected /matrix/appservice-registration-irc.yaml to be a list of AS config files.

Half-Shot commented 1 year ago

I think the error speaks for itself, it's a list of files and you've given it a string:

app_service_config_files: ["/matrix/appservice-registration-irc.yaml"]

Synapse should really be crashing on this.

ajohns92a commented 1 year ago

I think the error speaks for itself, it's a list of files and you've given it a string:

app_service_config_files: ["/matrix/appservice-registration-irc.yaml"]

Synapse should really be crashing on this.

Thank you for the response. I may be mistaken or possibly have put the file in the wrong location, however it does exist.

image

image

and I am invoking from the home folder with the following: node app.js -c config.yaml -f /matrix/appservice-registration-irc.yaml -p 9998

Could it be a permission issue? I tried with SUDO and received a different error, so that didn't resolve it.

image

When I execute as user, I receive the original error above.

Half-Shot commented 1 year ago

Your Synapse homeserver configuration is wrong. You've set app_service_config_files as string, but it should be a list. See https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#app_service_config_files

As for the other error, it looks like your Node version might possibly be very out of date. We only support Node 16 or greater. What is the output of node --version on your server?

ajohns92a commented 1 year ago

I think the error speaks for itself, it's a list of files and you've given it a string:

app_service_config_files: ["/matrix/appservice-registration-irc.yaml"]

Synapse should really be crashing on this.

I re-read your reply again and fixed the syntax in the homeserver.yaml (stopped passing a string, passed a list!) Thanks!! Working now.

ajohns92a commented 1 year ago

For what it's worth: image

Half-Shot commented 1 year ago

Weird, wonder why it didn't like the syntax then. Anyway, sounds like it's all working!