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
Name | Type | Description |
---|---|---|
botId | long | Bot ID |
scope | string | Telegram Passport element types requested by the service |
publicKey | string | Service's public key |
valueHashes | Vector<SecureValueHash> | Types of values sent and their hashes |
credentials | SecureCredentialsEncrypted | Encrypted values |
Result
Possible errors
Code | Type | Description |
---|
Can bots use this method?
No