question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RPCError: API_ID_INVALID

See original GitHub issue

I obtained api id and api hash… Using npx tgession, I entered the api id and hash but got the following error after I entered my phone number:

? API ID : 1234567
? API HASH : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
? Number : +62821123456789
RPCError: API_ID_INVALID
    at Object.RPCMessageToError (/home/nsrb/.npm/_npx/a24890428da1927f/node_modules/telegram/errors/index.js:24:12)
    at MTProtoSender._handleRPCResult (/home/nsrb/.npm/_npx/a24890428da1927f/node_modules/telegram/network/MTProtoSender.js:487:36)
    at MTProtoSender.<anonymous> (/home/nsrb/.npm/_npx/a24890428da1927f/node_modules/telegram/network/MTProtoSender.js:411:19)
    at Generator.next (<anonymous>)
    at fulfilled (/home/nsrb/.npm/_npx/a24890428da1927f/node_modules/telegram/network/MTProtoSender.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:94:5) {
  code: undefined
}

I use other combinations for phone number (using +, without +, using 0 instead of country code) but it still got the same error.

I doubled checked my API ID and Hash is the same.

my package.json contains “telegram”: “^1.7.15”

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
painorcommented, Jul 16, 2021

@painor I was able to get this working by using the logging in as a user route. It took a few tries but I figured out how to do this.

I was able to send myself test messages so it appears I’m authenticated.

The only issue I still have is understanding how to get the channel, I’m not sure how to write the code as I have the Channel ID but I think I’m missing something in how to write the code.

I tested with Pyrogram which is a Python Telegram app and I was able to get a response as to whether a user is in a channel or not.

data = await app.get_chat_member(-1001536877977, "ajroos2")

But when I use this code from GramJS I get an error message that says RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received -1_001_536_877_977.

const result = await client.invoke(
    new Api.channels.GetParticipant({
      channel: new Api.InputChannel({ channelId: -1001536877977 }),
      participant: new Api.ChannelParticipant({ userId: 1425866959 }),
    }),
  );

I’m not sure what code I should write to get the channel access to work, if you could help with that please?

Basically, I’m not sure what I should pass to the channel option of the GetParticipant constructor here to be a valid channel.

channel: new Api.InputChannel({ channelId: -1001536877977 }),

If you’re going to used Ids inside Api constructors don’t add the -100

You can possible just pass the id without constructor channel:-1001536877977

1reaction
nasyarobbycommented, Jul 16, 2021

Thanks! I see that it is not the library issue so I will close it for now… 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

Telegram - Getting AUTH_KEY_UNREGISTERED and ...
Okay so I solved my issue. I chose to use the Logging in as a User option where you enter your Telegram cellphone...
Read more >
auth.sendCode - Telegram APIs
API ID invalid. 400, API_ID_PUBLISHED_FLOOD, This API id was published somewhere, you can't use it now. 500, AUTH_RESTART, Restart the authorization ...
Read more >
pyrogram.types.InlineKeyboardButton Example - Program Talk
Here are the examples of the python api pyrogram.types.InlineKeyboardButton taken from open source projects. By voting up you can indicate which examples are ......
Read more >
Error Handling — Pyrogram Documentation
The father of all errors is named RPCError and is able to catch all Telegram API related errors. This error is raised every...
Read more >
PhoneCodeExpired The confirmation code has expired ...
ApiIdInvalid : app.disconnect() return 'The key is invalid' except: return ... line 411, in _send RPCError.raise_it(result, type(data)) File "C:\Program ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found