---
sidebar_position: 4
description: Get service account token and other functions to work with Google Sheets 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 Sheets]
---

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

# Get service account token
 Gets authorization token by service account data



`Function GetServiceAccountToken(Val Data, Val Scope, Val Expire = 3600) Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Data | --auth | Arbitrary | &#x2714; | JSON authorization data as a file, collection or binary data |
  | Scope | --scope | Array Of String | &#x2714; | Scope or array of scopes |
  | Expire | --exp | Number | &#x2716; | Token lifetime in seconds |

  
  Returns:  Map Of KeyAndValue - serialized JSON response from Google

:::tip
List of available scopes: [developers.google.com](https:

developers.google.com/identity/protocols/oauth2/scopes)
:::
<br/>


```bsl title="1C:Enterprise/OneScript code example"
    Data = "https://hut.openintegrations.dev/secret_test_data/google_service.json"; // URL, binary Data, file or collection

    Scope = New Array;
    Scope.Add("https://www.googleapis.com/auth/calendar");
    Scope.Add("https://www.googleapis.com/auth/drive");
    Scope.Add("https://www.googleapis.com/auth/spreadsheets");

    Result = OPI_GoogleSheets.GetServiceAccountToken(Data, Scope);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # JSON data can also be passed as a path to a .json file
            
            oint gsheets GetServiceAccountToken \
             --auth "{'type':'service_account','project_id':'openintegrations','private_key_id':'***','private_key':'***','client_email':'***','client_id':'***','auth_uri':'https://accounts.google.com/o/oauth2/auth','token_uri':'***','auth_provider_x509_cert_url':'https://www.googleapis.com/oauth2/v1/certs','client_x509_cert_url':'***','universe_domain':'googleapis.com'}" \
             --scope "['https://www.googleapis.com/auth/calendar','https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/spreadsheets']"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: JSON data can also be passed as a path to a .json file
            
            oint gsheets GetServiceAccountToken ^
             --auth "{'type':'service_account','project_id':'openintegrations','private_key_id':'***','private_key':'***','client_email':'***','client_id':'***','auth_uri':'https://accounts.google.com/o/oauth2/auth','token_uri':'***','auth_provider_x509_cert_url':'https://www.googleapis.com/oauth2/v1/certs','client_x509_cert_url':'***','universe_domain':'googleapis.com'}" ^
             --scope "['https://www.googleapis.com/auth/calendar','https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/spreadsheets']"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "access_token": "***",
 "expires_in": 3599,
 "token_type": "***"
}
```
