I'm using the Node.js GramJS Telegram npm package to query the Telegram API. I also tested this with the @mtproto/core and I'm getting the same AUTH_KEY_UNREGISTERED and API_ID_INVALID RPCErrors with both NPM packages.
I copied both the api_id and api_hash from the site and into the apiId and apiHash variables.
I don't know if someone could test this code to see if it works as is, and perhaps it's an issue with Telegram and the API tokens that I received?
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions/index.js";
const apiId = 1234567;
const apiHash = "this has the api_hash from the telegram website in my code";
const session = new StringSession("");
const client = new TelegramClient(session, apiId, apiHash);
(async function run() {
await client.connect();
console.log("You should now be connected.");
console.log(client.session.save());
const result = await client.invoke(
new Api.channels.GetParticipant({
channel: new Api.InputChannel({ channelId: -1001536877977 }),
participant: new Api.ChannelParticipant({ userId: 1425866959 }),
}),
);
console.log(result); // prints the result
})();