GramJS

account.AcceptAuthorization

Sends a Telegram Passport authorization form, effectively sharing data with the service

Example

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

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.account.AcceptAuthorization({
      botId: BigInt("-4156887774564"),
      scope: "some string here",
      publicKey: "some string here",
      valueHashes: [
        new Api.SecureValueHash({
          type: new Api.SecureValueTypePersonalDetails({}),
          hash: Buffer.from("arbitrary data here"),
        }),
      ],
      credentials: new Api.SecureCredentialsEncrypted({
        data: Buffer.from("arbitrary data here"),
        hash: Buffer.from("arbitrary data here"),
        secret: Buffer.from("arbitrary data here"),
      }),
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.Bool = await client.invoke(
    new Api.account.AcceptAuthorization({
      botId: BigInt("-4156887774564"),
      scope: "some string here",
      publicKey: "some string here",
      valueHashes: [
        new Api.SecureValueHash({
          type: new Api.SecureValueTypePersonalDetails({}),
          hash: Buffer.from("arbitrary data here"),
        }),
      ],
      credentials: new Api.SecureCredentialsEncrypted({
        data: Buffer.from("arbitrary data here"),
        hash: Buffer.from("arbitrary data here"),
        secret: Buffer.from("arbitrary data here"),
      }),
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
botIdlongBot ID
scopestringTelegram Passport element types requested by the service
publicKeystringService's public key
valueHashesVector<SecureValueHash>Types of values sent and their hashes
credentialsSecureCredentialsEncryptedEncrypted values

Result

Bool

Possible errors

CodeTypeDescription

Can bots use this method?

No