Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Last active January 9, 2022 18:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tanaikech/4656b1b01128d27f291cee317553ea6d to your computer and use it in GitHub Desktop.
Save tanaikech/4656b1b01128d27f291cee317553ea6d to your computer and use it in GitHub Desktop.
Retrieving ClientId using Google Apps Script

Retrieving ClientId using Google Apps Script

This is a sample script for retrieving clientId using Google Apps Script.

var accessToken = ScriptApp.getOAuthToken();
var url = "https://www.googleapis.com/oauth2/v3/tokeninfo";
var params = {
  method: "post",
  headers: {"Authorization": "Bearer " + accessToken}
};
var res = UrlFetchApp.fetch(url, params).getContentText();
var clientId = JSON.parse(res).azp;
Logger.log(clientId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment