How Telegram login for websites works, the current sign-in flow and the older widget, how to verify logins on your server, link accounts safely and fix common errors.
To add "Log In With Telegram" to your website, you create a Telegram bot with @BotFather, register your website with that bot, show Telegram's login button, and verify the signed data Telegram sends back on your server before signing the person in. Telegram confirms who the user is inside their Telegram app, so your site never sees their password or login code.
This guide explains the concepts, the two ways to integrate (Telegram's current sign-in flow based on OpenID Connect, and the older login widget many sites still run), how to verify each one in plain words, how to link Telegram identities to your own accounts, and how to fix the errors people hit most often. It describes the steps without code; the official developer pages hold the exact parameter names and should be your reference while building.
Every login involves three parties: the person signing in, Telegram, and your website. Your bot is how Telegram knows which website is asking.
Step 5 is the whole security of the system. Anyone can send your site data that looks like a Telegram user. Only the signature proves Telegram vouched for it.
Telegram shares limited profile information:
With the current sign-in flow, a phone number can be requested as an optional extra, and the user must agree to share it. Telegram does not give you the user's email address or password.
The numeric ID is the only field you should rely on to identify someone. Names and usernames can change or be absent. Our guide to getting a Telegram chat or user ID explains what these IDs are.
Have these ready:
Keep the bot token, and any client secret Telegram issues, out of your front-end code and your public repository. Anyone holding the token controls your bot.
Telegram's developer documentation now describes a sign-in flow built on the OpenID Connect standard, and lists the older JavaScript login widget as a legacy option. Both appear on live sites, so it helps to know each.
The current sign-in flow (OpenID Connect). It follows the same pattern as signing in with many other identity providers: your site redirects the user to Telegram, Telegram redirects back with a short-lived code, and your server exchanges that code for a signed token describing the user. If you already use an authentication library that supports OpenID Connect, this is usually the cleaner choice, and it supports extras like requesting a phone number with consent.
The legacy login widget. A small script on your page draws the button. After the user approves, the widget passes the user data and a hash either to a JavaScript function on your page or by redirecting to a URL you choose. Your server checks the hash using your bot token. It is simple and widely documented, but Telegram's documentation marks it as archived, so prefer the current flow for new projects unless you have a reason not to.
Login buttons inside Telegram. A bot can send a message with a special button that signs the user in to your website when tapped, without a separate approval screen. This is useful when users already talk to your bot. It uses the same kind of signed data as the widget.
Mini Apps. If your site runs inside Telegram, use the Mini App launch data instead of either login method.
The rest of this guide covers the first two in detail, because they are what most websites need.
This section assumes you use an OpenID Connect library for your language or framework, which is strongly recommended. Writing the protocol by hand is possible but easy to get subtly wrong.
Telegram only completes logins and redirects to addresses you registered. A redirect address that differs by a single character, such as a missing trailing slash or http instead of https, will be refused.
Telegram publishes a discovery document for its sign-in service. Most OpenID Connect libraries can read it automatically and fill in the authorization address, the token address and the public keys used to sign tokens. If your library needs them entered by hand, take them from Telegram's documentation.
Set:
Telegram's documentation notes that it does not currently offer a separate user-info endpoint; the user's details arrive inside the signed ID token. Some libraries try to call a user-info endpoint by default, so turn that off if login fails at that point.
When the user clicks your button, your server or library builds the authorization request. Alongside the client ID, redirect address and scopes, it includes:
The user is sent to Telegram, sees which bot and site are asking, and approves.
Telegram returns the user to your redirect address with a code and the state.
Do not read anything from the token until it passes these checks. A good library does them for you; confirm it is configured to.
Only then read the user's identifier and profile details from it.
Look up the Telegram user ID in your database. If you find a linked account, sign that user in. If not, create an account or start your linking flow, described later. Then issue your own session cookie as you would for any login. Do not keep using the Telegram token as your session.
Many existing sites use this, and some tutorials still describe it. If you maintain such a site, or have a reason to choose it, these are the steps.
In @BotFather, send the set-domain command, choose your bot, and enter your website's domain. The widget only works on the domain linked to the bot. One bot has one linked domain for this purpose, so sites on several domains often use one bot per domain.
Telegram's widget page lets you choose your bot, the button size, whether to show the user's photo, and how you want to receive the data:
You can also ask for permission for your bot to send the user messages. If the user agrees, your bot can write to them later, for example to send login alerts or notifications.
Place the generated script where the button should appear.
The data contains the user fields, the authentication time, and a field called hash. Verification works like this, described in words:
If any step fails, refuse the login.
As with the current flow, look up the user ID, sign in or create the account, and issue your own session.
If your site already has email accounts, plan how Telegram identities join them. Mistakes here cause either duplicate accounts or, worse, one person getting into another's account.
Store the numeric Telegram ID against the account. Never identify a user by Telegram username or display name. A username can be released and claimed by someone else, and names are not unique.
The safe pattern:
Do not merge accounts automatically because a Telegram name matches an existing name, or because a phone number looks the same. Matching on unverified details is how accounts get taken over.
Create a new account keyed by the Telegram ID. Remember it has no email address. If your site sends email, ask for one separately and verify it, or design the features that need email to work without it.
Let users disconnect Telegram from their account. If Telegram is their only login method, ask them to add another one first, or they will lock themselves out.
A login on its own does not let your bot message the user. A bot can only write to people who have started it or allowed it to.
Use this for useful things the user expects, such as security alerts or order updates. Unwanted promotional messages lead to blocks and reports. Our guide to sending broadcast messages to bot subscribers covers consent and rate limits.
A correct integration can still lose users if the flow confuses them. A few choices make a big difference.
Put it beside your other sign-in options, with the same size and weight. If Telegram is the main way your audience signs in, for example a site built around a Telegram community, put it first.
On a phone, approving a login often means switching to the Telegram app and back to the browser. People who are not expecting that may think something broke. A short line under the button, such as "You will confirm in Telegram, then return here", reduces abandoned logins.
Unless your site is only for Telegram users, keep another way to sign in. Someone who does not use Telegram should never reach a dead end.
After approval, send the user back to the page they were on, not always to the home page. Store the page they started from before the login begins, and return them to it afterwards.
On the account page, show the connected Telegram name and photo, and a clear button to disconnect. People who use several Telegram accounts need to see which one they linked.
This is a hypothetical project to show how the pieces fit together.
A forum for a hobby community already has email accounts. Most members also belong to its Telegram group, and many have asked to sign in with Telegram.
The team decides:
The result is a login that existing members can adopt without losing their history, and new members can use without creating a password.
Telegram only accepts logins from registered addresses. A local development address usually will not match. Common approaches are a separate test bot registered to a staging domain, or a secure tunnel that gives your local server a public HTTPS address you can register.
Use a separate bot for testing so you never put production secrets on a development machine.
The domain linked to the bot does not match the page. Check the domain you registered, including whether you used the bare domain or a subdomain. After changing it, reload the page fully.
Work through the list in "Details that break verification". The most common causes are building the string from URL-encoded values, using the token directly as the key, and using an old token.
It may be trying to call a user-info endpoint, which Telegram does not currently provide. Read the user details from the ID token instead.
Telegram sends the profile at the time of login. Update your stored name and photo on each login if you want them to stay current.
Tell users plainly what you receive and keep. A short line next to the button helps: for example, that you will receive their Telegram name, username and photo, and never their messages or phone number unless they choose to share it.
Users can review and disconnect websites they logged into with Telegram from inside Telegram's settings. If someone disconnects, your existing session for them is not automatically ended, so offer a normal "log out" and account deletion on your site as well.
Store only what you use. If you do not display photos, do not keep the photo link. If you request a phone number, have a clear reason. Data protection laws differ by country; this is general information, not legal advice.
Yes. Creating a bot and using Telegram login for your website does not cost anything from Telegram.
Not the email. With the current sign-in flow you can request the phone number, and the user must agree to share it. The legacy widget does not provide a phone number.
With the current flow you can register several allowed addresses for one bot. With the legacy widget, a bot is linked to one domain, so separate domains usually need separate bots.
For a new site, the current sign-in flow is the one Telegram's documentation now describes as standard, and it works with common authentication libraries. Keep the widget if you already have a working, correctly verified setup and no need to change.
Telegram login proves which Telegram account a visitor has. Telegram Passport lets users share identity documents they stored with Telegram, for services that need them. Our guide to Telegram Passport explains it.
Yes, if you just want visitors to message you. That needs no bot or verification. See our guide to adding a Telegram chat button.
Telegram login lets visitors sign in to your website with the Telegram account they already have. Create a bot, register your site with it, show Telegram's button, and verify every login on your server: with the current flow by validating the signed ID token, or with the legacy widget by recomputing the hash from your bot token and checking the authentication time. Identify users by their numeric Telegram ID, link accounts only from a signed-in session, keep secrets off the front end, and tell users what you store. Use Telegram's developer documentation as the reference for exact parameter names, since they can change.
Ownership confirmed through our claim process — not an endorsement of their content.
Founder of Telegram.
The official Telegram on Telegram. Much recursion. Very Telegram. Wow.
Telegram Premium – a subscription that unlocks dozens of exclusive features.
Binance Official English Group Binance Official Chinese Group Binance English Announcements Binance Chinese Announcements
is a modern crypto news and research platform covering the latest developments across digital assets, markets, regulation, and blockchain technology.
Technical analysis & high-probability trade setups. Price action, market structure, risk control.
BlackBlock Markets exists to observe how capital moves before it becomes obvious.
This channel focuses exclusively on what shapes global finance. Macroeconomics, markets, liquidity, central banks.
Clear long & short signals for BTC, ETH & liquid altcoins. AI-backed analysis, real-time execution.