Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
Telegram Web Bots data validation in JavaScript

I've tried to do user verification script for telegram web app for bots. I have no idea how to fix it.

import sha256 from 'js-sha256'

const telegram = window.Telegram.WebApp
const bot_token = '<bot-token>'
const data_check_string = telegram.initData

    var secret_key = sha256.hmac.create(bot_token).update("WebAppData")
    var hash = sha256.hmac.create(data_check_string).update(secret_key).hex();

   if ( hash == telegram.initDataUnsafe.hash) {
       // data is from Telegram
   }

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try to look to node js implementation, I tried to well comment it using official telegram pseudocode. Maybe it helps you.

But in my convinience this validation need to execute at backend because in another case you compromise your bot secret token

https://gist.github.com/konstantin24121/49da5d8023532d66cc4db1136435a885

about 4 years ago · Juan Pablo Isaza Denunciar

0

The stated code to be used for validation in the official documentation is this:

data_check_string = ...
secret_key = HMAC_SHA256(<bot_token>, "WebAppData")
if (hex(HMAC_SHA256(data_check_string, secret_key)) == hash) {
  // data is from Telegram
}

please try to implement it as it is documented.

The link referring to this problem is: Telegram API validation

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda