tanaike

The Thinker

Using Google API Client Library (gapi) for JavaScript with Service Account

Gists This is a sample script for using Google API Client Library (gapi) for JavaScript with the service account. Unfortunately, in the current stage, gapi cannot directly use the service account. So, in this case, it is required to implement the script for retrieving the access token from the service account. In this report, I would like to introduce the method for using gapi with the service account using a Javascript library.

Javascript library - GetAccessTokenFromServiceAccount_js

Overview This is a Javascript library to retrieve the access token from the Google Service Account. Ref Description I have already posted the sample script for retrieving the access token from the Google Service Account. Ref But, when I use this script, I thought that when this was published as the Javascript library, it will be useful. So I created this. Install <script src="getaccesstokengromserviceaccount_js.min.js"></script> Or, using jsdelivr cdn <script src="https://cdn.jsdelivr.net/gh/tanaikech/GetAccessTokenFromServiceAccount_js@master/getaccesstokengromserviceaccount_js.min.js"></script> You can see the detail of this at https://github.

Retrieving Hidden Rows and Showing Rows by Filter View on Google Spreadsheet using Google Apps Script

Gists This is a sample script for retrieving the hidden rows and showing rows by the filter view on Google Spreadsheet using Google Apps Script. In the current stage, there are no methods for directly retrieving the hidden rows and showing rows by the filter view in Spreadsheet service (SpreadsheetApp). And, isRowHiddenByFilter of Class Sheet cannot be used for the filter view. But, fortunately, when Sheets API is used, the filter view can be retrieved and created.

Benchmark: Process Costs for Retrieving 1st Empty Cell and 1st Non Empty Cell of Specific Column in Google Spreadsheet using Google Apps Script

Gists Introduction Here, I would like to report the process costs for retrieving the 1st empty cell or 1st non empty cell of the specific column of Google Spreadsheet using Google Apps Script (GAS). For this situations, the following 2 patterns can be considered. Retrieving 1st empty cell of specific column by searching from TOP of sheet Retrieving 1st NON empty cell of specific column by searching from BOTTOM of sheet

Retrieving Access Token using Service Account for PHP without using googleapis

Gists This is a sample PHP script to retrieve the access token from Service Account of Google without using googleapis. Sample script <?php $private_key = "-----BEGIN PRIVATE KEY-----\n###-----END PRIVATE KEY-----\n"; // private_key of JSON file retrieved by creating Service Account $client_email = "###"; // client_email of JSON file retrieved by creating Service Account $scopes = ["https://www.googleapis.com/auth/drive.readonly"]; // Sample scope $url = "https://www.googleapis.com/oauth2/v4/token"; $header = array("alg" => "RS256", "typ" => "JWT"); $now = floor(time()); $claim = array( "iss" => $client_email, "sub" => $client_email, "scope" => implode(" ", $scopes), "aud" => $url, "exp" => (string)($now + 3600), "iat" => (string)$now, ); $signature = base64_encode(json_encode($header, JSON_UNESCAPED_SLASHES)) .