Desscription of a problem:
There are tg bots,
which has oppportunities to open websites in a webview(iframe)
,
inside of a telegram app. Whenewer you press on a button inside bot,
it opens a webview with specific url.
This allows to underrstand for opened website,
that this url was opened buy SOME_USER
and his auth data is correct (at least I think so).
Example of an url:
https://SOME_WEBSITE/#/login?
user=USER_GUID
&tgWebAppVersion=7.2
&linkBot=https://t.me/SOME_BOT_bot
&tgWebAppData=query_id=QUERY_ID
&user={
"id":1,
"first_name":"FirstName",
"last_name":"LastName",
"username":"UserName",
"language_code":"en",
"allows_write_to_pm":true
}
&auth_date=1713881657
&hash=SOME_HASH
&tgWebAppVersion=7.2
&tgWebAppPlatform=weba
&tgWebAppThemeParams={"bg_color":"#ffffff", ......... , "destructive_text_color":"#e53935"}
This url is not generated buy bot. The bot contains only
https://SOME_WEBSITE/#/login
this part inside of a button. But when you press on a button,
the telegram itself add all this specific auth data to url params.
And opens this url in a webview(I’ve have intercept this url after pressing the button).
Question:
“How can I generate such params for URL, by my own ?”
What I’ve tried alredy:
- reading docs and found perhaps something I need “https://corefork.telegram.org/api/url-authorization”
- try to use this methods(
Messages_RequestUrlAuth
,Messages_AcceptUrlAuth
)
from “wtelegramclient” library. Whitout success, maybe doing something wrong(receiving null’s)
var resolvedUser = await _client.Contacts_ResolveUsername("someBotUserName");
var msgBase = await _client.Messages_GetHistory(new InputPeerUser(resolvedUser.User.ID, resolvedUser.User.access_hash), limit: 1);
var test1 = await _client.Messages_RequestUrlAuth(url: "https://some_url");
var test2 = await _client.Messages_AcceptUrlAuth(new InputPeerUser(resolvedUser.User.ID, resolvedUser.User.access_hash), msg_id: msgBase.Messages[0].ID, url: "https://some_url");
- searched different github’s repos for
RequestUrlAuth
examples or mentions. - searched stackowerflow, there is something far away close to my question, but the questions
don’t have answers or didn’t help.
UPD:(↓)
If anything is unclear, I will provide here updates for your feedback