fetch-matrix-access-token/main.js
Nikhil Nawgiri fc614bd6cc Add main.js
2024-08-25 00:45:45 +02:00

21 lines
673 B
JavaScript

const sdk = require("matrix-bot-sdk");
const config = require("./config.js");
const { MatrixAuth } = sdk;
const {
homeserverUrl,
username,
password,
} = config;
// This will be the URL where clients can reach your homeserver. Note that this might be different
// from where the web/chat interface is hosted. The server must support password registration without
// captcha or terms of service (public servers typically won't work).
const login = async () => {
const auth = new MatrixAuth(homeserverUrl);
const client = await auth.passwordLogin(username, password);
console.log("Copy this access token to your bot's config: ", client.accessToken);
}
login();