Skip to content

Instantly share code, notes, and snippets.

@rhyskentish
Created October 4, 2019 14:49
Show Gist options
  • Save rhyskentish/4a2c94bd88eb814c28a80c00d67f189f to your computer and use it in GitHub Desktop.
Save rhyskentish/4a2c94bd88eb814c28a80c00d67f189f to your computer and use it in GitHub Desktop.
/**
* namespace to deal with oauth
* @namespace Oauth
*/
var Goth = (function(ns) {
/**
* get a goa or fail
* @param {string} packageName the package name
* @param {PropertiesService} [props=ScriptProperties]
* @return {Goa} a goa
*/
ns.getGoa = function (packageName,props) {
return cGoa.GoaApp.createGoa(
packageName,
props || PropertiesService.getScriptProperties()
).execute();
}
/**
* get a token or fail
* @param {string} packageName the package name
* @param {PropertiesService} [props=ScriptProperties]
* @return {Goa} a goa
*/
ns.getToken = function (packageName,props) {
var goa = ns.getGoa (packageName, props);
if (!goa.hasToken()) {
throw 'no token retrieved';
}
return goa.getToken();
}
return ns;
}) (Goth || {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment