Seamless Telegram Login

Bots may ask users to login to a certain website via Telegram when clicking on certain URL buttons in inline keyboards.

When the user clicks on keyboardButtonUrlAuth, messages.requestUrlAuth should be called, providing the button_id of the button and the ID and peer of the container message. The returned urlAuthResultRequest object will contain more details about the authorization request:

  • The domain parameter will contain the domain name of the website on which the user will log in (example: comments.app).
  • The bot parameter will contain info about the bot which will be used for user authorization (example: DiscussBot).
  • The request_write_access will be set if the bot would like to send messages to the user.

The info should be shown in a prompt:

TITLE

If the user agrees to login to the URL, messages.acceptUrlAuth should be called (eventually setting the write_allowed if the permission was requested and the user consented). The result will be a urlAuthResultAccepted with the final URL to open, which will include a query string with the requested info and a hash that must be verified upon receival by the service.

urlAuthResultDefault could also be returned, instead, in which case the url of the keyboardButtonUrlAuth must be opened, instead. The same must be done if the user opens the link while refusing the authorization request.