Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /**
  2. * namespace to deal with oauth
  3. * @namespace Oauth
  4. */
  5. var Goth = (function(ns) {
  6.  
  7. /**
  8. * get a goa or fail
  9. * @param {string} packageName the package name
  10. * @param {PropertiesService} [props=ScriptProperties]
  11. * @return {Goa} a goa
  12. */
  13. ns.getGoa = function (packageName,props) {
  14.  
  15. return cGoa.GoaApp.createGoa(
  16. packageName,
  17. props || PropertiesService.getScriptProperties()
  18. ).execute();
  19.  
  20. }
  21.  
  22. /**
  23. * get a token or fail
  24. * @param {string} packageName the package name
  25. * @param {PropertiesService} [props=ScriptProperties]
  26. * @return {Goa} a goa
  27. */
  28. ns.getToken = function (packageName,props) {
  29.  
  30. var goa = ns.getGoa (packageName, props);
  31.  
  32. if (!goa.hasToken()) {
  33. throw 'no token retrieved';
  34. }
  35. return goa.getToken();
  36. }
  37.  
  38. return ns;
  39. }) (Goth || {});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement