Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram Passport Javascript SDK

I'm kinda new with the Telegram Bot API and in the bot I would like to verify a user's age via Telegram Passport

I am trying to recreate their Javascript SDK. The button appears and opens Telegram Passport but I receive the error

Could not get authorization form. PUBLIC_KEY_REQUIRED

I already inserted my public key but I still keep getting the error. It would be a big help if someone could replicate their example and tell me what I'm doing wrong.

like image 382
Patrick Ian Co Avatar asked Jul 15 '26 11:07

Patrick Ian Co


1 Answers

The public key has to be provided in 2 places.

The public_key property of the AuthParameters object that is passed to Telegram.Passport.createAuthButton should be set to your public key. I am assuming that you did this when you stated that you inserted your public key.

You must also use the BotFather to set the public key for your bot. The command you use to start the process with the BotFather is /setpublickey. When you enter that command the BotFather will ask you which of your bots the key should apply to, and then it waits for you to paste in the public key in a message. If all goes well, the BotFather will reply "Success! Public key updated. /help".

I saw the same error message that you described when I had put the public key in the AuthParameters, but had failed to upload it to the BotFather.

like image 162
jwilliamson45 Avatar answered Jul 17 '26 23:07

jwilliamson45