auth.importBotAuthorization

Login as a bot

Example

const {Api, TelegramClient} = require('telegram');
const {StringSession} = require('telegram/sessions');

const session = new StringSession('');
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
    const result = await client.invoke(new Api.auth.importBotAuthorization({
        flags: 8379541,
        apiId: 8032379,
        apiHash: 'random string here',
        botAuthToken: 'random string here',
        }));
    console.log(result); // prints the result
})();

TL schema

auth.authorization#cd050916 flags:# tmp_sessions:flags.0?int user:User = auth.Authorization;
auth.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization;
---functions---
auth.importBotAuthorization#67a3ff2c flags:int api_id:int api_hash:string bot_auth_token:string = auth.Authorization;

Parameters

Name

Type

Description

flags

Reserved for future use

api_id

Application identifier (see. App configuration)

api_hash

Application identifier hash (see. App configuration)

bot_auth_token

Bot token (see bots)

Result

Returns an auth.Authorization object with information on the new authorization.

Possible errors

Code

Type

Description

400

ACCESS_TOKEN_EXPIRED

Bot token expired

400

ACCESS_TOKEN_INVALID

The provided token is not valid

400

API_ID_INVALID

The api_id/api_hash combination is invalid

401

AUTH_KEY_INVALID

Auth key invalid

Can bots use this methd ?

yes

Last updated