skip to Main Content

api_hash and api_id ​​are used for telethon and pyrogram libraries, etc. to build Userbot using Telegram API and its not the same API that BotFather gives you.

you can get api_hash and api_id from my.telegram.org in API development tools section.

After three weeks of trying and testing IPs from more than 30 different countries, as well as using VPS with Turkish and American servers, I still could not get the api_hash and api_id values ​​for even one of my Telegram accounts.

The phone numbers I used were from Argentina, Estonia, America, and Iran.
My location is Iran and I have used premium VPN servers such as NordVPN, Hotspot Shield, v2ray protocol, as well as VPS in Turkey and America to change the IP.

The browser adblocker has been turned off and it has been tested in 3 browsers: Edge, Chrome, Firefox in Incognito and Normal mode.

Request Data:

App Title: testappnumber12
Short name: testapp12
URL: www.telegram.org
Platform: Android / Desktop
Description: anything / skip

Response:

ERROR

enter image description here

Programmatically requests method | Still gives ERROR

I wrote a simple request code with python and I used session to hold my session and work with that.
I did it because I wanted to use my UK linux VPS with a clean IP.
Telegram keeps returning the ERROR and I think this is a problem on Telegram’s side, not a problem on my side. To be sure, can you also try to get the api_hash and api_id guys?

My python code for request to Telegram programmatically:

import requests
from bs4 import BeautifulSoup


def main():

    send_password_url = 'https://my.telegram.org/auth/send_password'

    payload = {
        'phone': PHONE
    }

    response = session.post(url=send_password_url, data=payload)

    if response.status_code == 200:
        if response.text != "Sorry, too many tries. Please try again later." :
            random_hash = response.json()['random_hash']
        else:
            print(response.text)
            return
    else:
        print(f"Unsuccessful request. Status Code: {response.status_code}")
        return

    confirmation_code = input('Enter your confirmation code: ')

    login_url = 'https://my.telegram.org/auth/login'

    payload = {
        'phone': PHONE,
        'random_hash': random_hash,
        'password': confirmation_code
    }

    response = session.post(url=login_url, data=payload)

    if response.status_code == 200:
        if response.text != "Sorry, too many tries. Please try again later." :
            if response.text != "true":
                return
        else:
            print(response.text)
            return
    else:
        print(f"Unsuccessful request. Status Code: {response.status_code}")
        return

    apps_page = session.get('https://my.telegram.org/apps')
    soup = BeautifulSoup(apps_page.text, 'html.parser')
    page_hash = soup.find('input', attrs={'name': 'hash'}).get('value')

    print("hash:", page_hash)

    create_url = "https://my.telegram.org/apps/create"

    payload = {
        'hash': page_hash,
        'app_title': 'testapp12345',
        'app_shortname': 'testapp',
        'app_url': 'localhost',
        'app_platform': 'desktop',
        'app_desc': ''
    }

    response = session.post(url=create_url, data=payload)

    print("Telegram Response:", response.text)


if __name__ == '__main__':
    PHONE = int(input('Enter your phone number: (ex. 18880001234) '))
    session = requests.Session()
    main()
    input("Press Enter to exit...")

2

Answers


  1. I think maybe I know what’s the problem If you are getting a new bot token, telethon and pyrogram libraries won’t support you they are a little outdated you may need a shorter API id and that’s not gonna happen if you making a new bot!

    Login or Signup to reply.
  2. i have same problem, do you know any solution

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search