# auth.importAuthorization

Logs in a user using a key transmitted from his native data-centre.

## Example

{% tabs %}
{% tab title="Javascript" %}

```javascript
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.importAuthorization({
        id: 4965292,
        bytes: Buffer.from('some bytes here'),
        }));
    console.log(result); // prints the result
})();
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import {Api, TelegramClient} from 'telegram';
import {StringSession} from 'telegram/sessions';

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

(async function run() {
    const result: Api.auth.Authorization = await client.invoke(new Api.auth.importAuthorization({
        id: 4965292,
        bytes: Buffer.from('some bytes here'),
        }));
    console.log(result); // prints the result
})();
```

{% endtab %}
{% endtabs %}

## 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.importAuthorization#e3ef9613 id:int bytes:bytes = auth.Authorization;
```

## Parameters

|    Name   | Type                                          | Description       |
| :-------: | --------------------------------------------- | ----------------- |
|   **id**  | [int](https://core.telegram.org/type/int)     | User ID           |
| **bytes** | [bytes](https://core.telegram.org/type/bytes) | Authorization key |

## Result

[auth.Authorization](https://core.telegram.org/type/auth.Authorization)

## Possible errors

| Code | Type                 | Description                           |
| :--: | -------------------- | ------------------------------------- |
|  400 | AUTH\_BYTES\_INVALID | The provided authorization is invalid |
|  400 | USER\_ID\_INVALID    | The provided user ID is invalid       |

## Can bots use this methd ?

### yes

## Related pages


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://painor.gitbook.io/gramjs/registration-and-authorization/auth.importauthorization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
