Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can access to WebAppUser in Telegram web app

I created a Web App with Telegram and ReactJS, after that I enabled web app debug mod to see inspect options.

The only way I can get user information is:

var search = Telegram.WebApp.initData
var converted = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g,'":"') + '"}', function(key, value) { return key===""?value:decodeURIComponent(value) })
JSON.parse(converted.user)

Based on: https://core.telegram.org/bots/webapps#webappinitdata

But all the options the document calls are not there and there is another API which I need it is WebAppUser document, and again I can not access it.

My question is how can I be able to access it?

I see this JS file that Telegram says to add in our HTML, but I could not find the WebAppUser into it.

<script src="https://telegram.org/js/telegram-web-app.js"></script>

Short Video and demo: https://www.youtube.com/watch?v=rKFZd2rWk24

Thank you in advance.

like image 555
Shahryar Tavakkoli Avatar asked Jan 29 '26 17:01

Shahryar Tavakkoli


1 Answers

I guess that WebAppUser section describes the properties of a user encoded in window.Telegram.WebApp.initData. So it should be safe to use validated and decoded information stored in window.Telegram.WebApp.initData to obtain a user data.

NB! It's my guess tho. I faced the same question in fact.

like image 167
mitenka Avatar answered Feb 01 '26 23:02

mitenka