---
sidebar_position: 2
description: Get token by code and other functions to work with Google Calendar in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Google Calendar]
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Get token by code
 Gets token by code from browser authorization



`Function GetTokenByCode(Val ClientID, Val ClientSecret, Val Code) Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | ClientID | --id | String | &#x2714; | Client ID |
  | ClientSecret | --secret | String | &#x2714; | Client secret |
  | Code | --code | String | &#x2714; | Code from browser |

  
  Returns:  Map Of KeyAndValue - serialized JSON response from Google



```bsl title="1C:Enterprise/OneScript code example"
    ClientID     = "345925493105-641q49rl4oflrtr46fkgqf5upiltr4bg.apps.googleusercontent.com";
    ClientSecret = "GOCSPX-v--MJyEjtV...";
    Code         = "4/0AeaYSHBDZAbAtChyjMxPKa0DXIilJYYcVCgKYzA_CPmCPSt1mg_KqxI4w5CP3lTlYibpGg";

    Result = OPI_GoogleCalendar.GetTokenByCode(ClientID, ClientSecret, Code);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            oint gcalendar GetTokenByCode \
             --id "345925493105-641q49rl4oflrtr46fkgqf5upiltr4bg.apps.googleusercontent.com" \
             --secret "***" \
             --code "4/0AeaYSHBDZAbAtChyjMxPKa0DXIilJYYcVCgKYzA_CPmCPSt1mg_KqxI4w5CP3lTlYibpGg"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            oint gcalendar GetTokenByCode ^
             --id "345925493105-641q49rl4oflrtr46fkgqf5upiltr4bg.apps.googleusercontent.com" ^
             --secret "***" ^
             --code "4/0AeaYSHBDZAbAtChyjMxPKa0DXIilJYYcVCgKYzA_CPmCPSt1mg_KqxI4w5CP3lTlYibpGg"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "error": "invalid_grant",
 "error_description": "Bad Request"
}
```
