Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Last active January 9, 2022 18:51
Embed
What would you like to do?
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