Get service account token
Gets authorization token by service account data
- Parameters
- Advanced call ?
Function GetServiceAccountToken(Val Data, Val Scope, Val Expire = 3600) Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Data | --auth | Arbitrary | ✔ | JSON authorization data as a file, collection or binary data |
| Scope | --scope | Array Of String | ✔ | Scope or array of scopes |
| Expire | --exp | Number | ✖ | Token lifetime in seconds |
Returns
Map Of KeyAndValue - serialized JSON response from Google
This method has no additional advanced call parameters.
tip
List of available scopes: [developers.google.com](https:
developers.google.com/identity/protocols/oauth2/scopes)
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_GoogleCalendar.GetServiceAccountToken(Data, Scope);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint gcalendar 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']"
:: JSON data can also be passed as a path to a .json file
oint gcalendar 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']"
Result
{
"access_token": "***",
"expires_in": 3599,
"token_type": "***"
}