SlideShare a Scribd company logo
OAUTH2 and Apps Script
It's not that complicated
Authentication
and
Authorization
How to use Goa to simplify
OAuth2 user and service
account handling in Apps
Script.
developers console
script ide
consuming tokens
More information at Desktop
Liberation
Apps Script
In the developers console
1. Create the project
2. Select the APIS to use
3. See which scopes the APIS require using the API explorer
4. Get credentials
a. Web client - take note of client ID and client secret
b. Service Account - download the JSON data to Drive
Developers
console How to set up an API project in
the Google Developers
consoleProject dashboard
…….
Developers console: 1. Create the project
Developers console: 2. Select the APIS to use
Developers console: 3. note scopes (API explorer)
Developers console: 4a. Get credentials (user)
(if using user Oauth2)
Developers console: 4b. Get credentials (service)
(if using Service account)
Apps Script How to set up Goa for OAuth2
and Service Accounts in the
Apps Script IDEThe Script IDE
In your script
1. Include the cGoa library (MZx5DzNPsYjVyZaR67xXJQai_d-phDA33)
2. Create a one off script to store credentials and run it
3. If a user Oauth2 account (instead of a service account)
a. Publish and run your App
b. Copy the redirect URI to the developer console from the consent screen
c. Allow the consent process to finish
4. Delete your one off script (or move it somewhere private)
Script IDE: 1. include cGoa library
MZx5DzNPsYjVyZaR67xXJQai_d-phDA33
Script IDE: 2a. create credentials script and run it
function oneOffScript() {
var options = {
packageName: 'goa-tutorial-user',
clientId: 'xxx.apps.googleusercontent.com',
clientSecret:'xxxx',
scopes : cGoa.GoaApp.scopesGoogleExpand (['pubsub','cloud-platform']),
service:'google'
};
// store one off
cGoa.GoaApp.setPackage (PropertiesService.getUserProperties(), options);
}
(if using user Oauth2)
function oneOffScript() {
var options = {
packageName: 'goa-tutorial-service',
fileId:'0B92xxxxxxjNDR28',
scopes : cGoa.GoaApp.scopesGoogleExpand (['pubsub','cloud-platform']),
service:'google_service'
};
cGoa.GoaApp.setPackage (PropertiesService.getScriptProperties(),
cGoa.GoaApp.createServiceAccount (DriveApp , options));
}
Script IDE: 2b. create credentials script and run it
(if using Service account)
the JSON key file id
function doGet(e) {
var goa = cGoa.GoaApp.createGoa ('goa-tutorial-user',
PropertiesService.getUserProperties()).execute (e);
if (goa.needsConsent()) {
return goa.getConsent();
}
return HtmlService.createHtmlOutput (goa.hasToken() ?
'your token has been stored' : 'failed to get token')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
Script IDE: 3a. Publish app and run it
(if using user Oauth2)
Script IDE: 3b. Copy redirect uri and origin to console
(if using user Oauth2)
Script IDE: 3c. Allow the consent process to complete
(if using user Oauth2)
function oneOffScript() {
….
}
function doGet() {
….
}
Script IDE: 4. delete one off script (and doGet)
scripts no longer needed
Apps Script How to consume Goa access
tokens in Apps Script projects
Using the token
Using Goa
1. Once Goa has been set up there is no need for any more interaction
2. Just fetch the access token and use it. It will be automatically refreshed
Using Goa: 1. Getting the token
var goa = cGoa.GoaApp.createGoa ('goa-tutorial-user',
PropertiesService.getUserProperties()).execute ();
if (goa.hasToken()) {
var token = goa.getToken();
}
same for both service account and user OAuth2
Just change property store and credentials name
Using Goa: 2. Using the token
var result = UrlFetchApp.fetch (apiUrl , {
header: {
authentication: 'Bearer ' + goa.getToken()
}
});
same for both service account and user OAuth2
More Goa
The source code, examples
and additional features of Goa,
including how to set up for API
providers other than Google
can be found at Desktop
Liberation
Further capabilities
Ad

More Related Content

What's hot (20)

Санал хураах кюмюлатив аргыг хэрэглэх журам
Санал хураах кюмюлатив аргыг хэрэглэх журамСанал хураах кюмюлатив аргыг хэрэглэх журам
Санал хураах кюмюлатив аргыг хэрэглэх журам
Umguullin Mongol Umguulugch
 
Санхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн заавар
Санхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн зааварСанхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн заавар
Санхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн заавар
Byambadrj Myagmar
 
Lab14
Lab14Lab14
Lab14
BPurev
 
стандарт өртгийн бүртгэл
стандарт өртгийн бүртгэлстандарт өртгийн бүртгэл
стандарт өртгийн бүртгэл
Enebish Vandandulam
 
Г.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛ
Г.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛГ.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛ
Г.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛ
batnasanb
 
Ашгийн өөрчлөлтийн шинжилгээ
Ашгийн өөрчлөлтийн шинжилгээАшгийн өөрчлөлтийн шинжилгээ
Ашгийн өөрчлөлтийн шинжилгээ
DOtgontsetseg
 
Ulsiin tusuv
Ulsiin tusuvUlsiin tusuv
Ulsiin tusuv
momish_77
 
Fluctuation
FluctuationFluctuation
Fluctuation
Odko Ts
 
Д.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талууд
Д.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талуудД.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талууд
Д.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талууд
batnasanb
 
олон улсын зах зээл дээр гарах стратеги
олон улсын зах зээл дээр гарах стратегиолон улсын зах зээл дээр гарах стратеги
олон улсын зах зээл дээр гарах стратеги
grane09
 
Тэнцвэржүүлсэн үнэлгээний арга. BSC
Тэнцвэржүүлсэн үнэлгээний арга. BSCТэнцвэржүүлсэн үнэлгээний арга. BSC
Тэнцвэржүүлсэн үнэлгээний арга. BSC
Мускаа Шдээ
 
Lekts11. murui shugaman regress buten
Lekts11.  murui shugaman regress butenLekts11.  murui shugaman regress buten
Lekts11. murui shugaman regress buten
Anhaa8941
 
statistic_ajiglalt
statistic_ajiglaltstatistic_ajiglalt
statistic_ajiglalt
oz
 
Macro l 2
Macro l 2Macro l 2
Macro l 2
hicheel2020
 
Lecture 11,12
Lecture 11,12Lecture 11,12
Lecture 11,12
Bbujee
 
Lekts 7 uil ajillagaanii shinjilgee
Lekts 7 uil ajillagaanii shinjilgeeLekts 7 uil ajillagaanii shinjilgee
Lekts 7 uil ajillagaanii shinjilgee
Byambadrj Myagmar
 
One&two way anova ph d
One&two way anova ph dOne&two way anova ph d
One&two way anova ph d
zorigoo.sph
 
зах зээлийн идэвхжилийн шинжилгээ
зах зээлийн идэвхжилийн шинжилгээзах зээлийн идэвхжилийн шинжилгээ
зах зээлийн идэвхжилийн шинжилгээ
Enebish Vandandulam
 
Санал хураах кюмюлатив аргыг хэрэглэх журам
Санал хураах кюмюлатив аргыг хэрэглэх журамСанал хураах кюмюлатив аргыг хэрэглэх журам
Санал хураах кюмюлатив аргыг хэрэглэх журам
Umguullin Mongol Umguulugch
 
Санхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн заавар
Санхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн зааварСанхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн заавар
Санхүүгийн тайланд шинжилгээ хийх үлгэрчилсэн заавар
Byambadrj Myagmar
 
стандарт өртгийн бүртгэл
стандарт өртгийн бүртгэлстандарт өртгийн бүртгэл
стандарт өртгийн бүртгэл
Enebish Vandandulam
 
Г.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛ
Г.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛГ.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛ
Г.Мөнгөнцэцэг - CAPM ЗАГВАР ба ӨРГӨТГӨЛ
batnasanb
 
Ашгийн өөрчлөлтийн шинжилгээ
Ашгийн өөрчлөлтийн шинжилгээАшгийн өөрчлөлтийн шинжилгээ
Ашгийн өөрчлөлтийн шинжилгээ
DOtgontsetseg
 
Ulsiin tusuv
Ulsiin tusuvUlsiin tusuv
Ulsiin tusuv
momish_77
 
Fluctuation
FluctuationFluctuation
Fluctuation
Odko Ts
 
Д.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талууд
Д.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талуудД.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талууд
Д.Дэлгэрмөрөн - Монгол оронд органик ХАА-н үйлдвэрлэл хөгжих боломж давуу талууд
batnasanb
 
олон улсын зах зээл дээр гарах стратеги
олон улсын зах зээл дээр гарах стратегиолон улсын зах зээл дээр гарах стратеги
олон улсын зах зээл дээр гарах стратеги
grane09
 
Тэнцвэржүүлсэн үнэлгээний арга. BSC
Тэнцвэржүүлсэн үнэлгээний арга. BSCТэнцвэржүүлсэн үнэлгээний арга. BSC
Тэнцвэржүүлсэн үнэлгээний арга. BSC
Мускаа Шдээ
 
Lekts11. murui shugaman regress buten
Lekts11.  murui shugaman regress butenLekts11.  murui shugaman regress buten
Lekts11. murui shugaman regress buten
Anhaa8941
 
statistic_ajiglalt
statistic_ajiglaltstatistic_ajiglalt
statistic_ajiglalt
oz
 
Lecture 11,12
Lecture 11,12Lecture 11,12
Lecture 11,12
Bbujee
 
Lekts 7 uil ajillagaanii shinjilgee
Lekts 7 uil ajillagaanii shinjilgeeLekts 7 uil ajillagaanii shinjilgee
Lekts 7 uil ajillagaanii shinjilgee
Byambadrj Myagmar
 
One&two way anova ph d
One&two way anova ph dOne&two way anova ph d
One&two way anova ph d
zorigoo.sph
 
зах зээлийн идэвхжилийн шинжилгээ
зах зээлийн идэвхжилийн шинжилгээзах зээлийн идэвхжилийн шинжилгээ
зах зээлийн идэвхжилийн шинжилгээ
Enebish Vandandulam
 

Similar to Goa tutorial (20)

Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
wesley chun
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
Kanda Runapongsa Saikaew
 
Using Google (Cloud) APIs
Using Google (Cloud) APIsUsing Google (Cloud) APIs
Using Google (Cloud) APIs
wesley chun
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
wesley chun
 
google drive and the google drive sdk
google drive and the google drive sdkgoogle drive and the google drive sdk
google drive and the google drive sdk
firenze-gtug
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
wesley chun
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
guest1af57e
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
Automatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos TabularesAutomatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos Tabulares
Gaston Cruz
 
The Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIThe Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror API
Gun Lee
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
European Innovation Academy
 
Exploring MORE Google (Cloud) APIs with Python
Exploring MORE Google (Cloud) APIs with PythonExploring MORE Google (Cloud) APIs with Python
Exploring MORE Google (Cloud) APIs with Python
wesley chun
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
wesley chun
 
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 RICOH THETA x IoT Developers Contest : Cloud API Seminar RICOH THETA x IoT Developers Contest : Cloud API Seminar
RICOH THETA x IoT Developers Contest : Cloud API Seminar
contest-theta360
 
Google Cloud Enpoints
Google Cloud EnpointsGoogle Cloud Enpoints
Google Cloud Enpoints
Mattia Gasperotti
 
Exploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overviewExploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overview
wesley chun
 
Building and Running Your App in the Cloud
Building and Running Your App in the CloudBuilding and Running Your App in the Cloud
Building and Running Your App in the Cloud
Brandon Minnick, MBA
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
wesley chun
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
wesley chun
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
wesley chun
 
Using Google (Cloud) APIs
Using Google (Cloud) APIsUsing Google (Cloud) APIs
Using Google (Cloud) APIs
wesley chun
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
wesley chun
 
google drive and the google drive sdk
google drive and the google drive sdkgoogle drive and the google drive sdk
google drive and the google drive sdk
firenze-gtug
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
wesley chun
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
guest1af57e
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
Automatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos TabularesAutomatizacion de Procesos en Modelos Tabulares
Automatizacion de Procesos en Modelos Tabulares
Gaston Cruz
 
The Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIThe Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror API
Gun Lee
 
Cloud Endpoints _Polymer_ Material design by Martin Görner
Cloud Endpoints_Polymer_Material design by Martin GörnerCloud Endpoints_Polymer_Material design by Martin Görner
Cloud Endpoints _Polymer_ Material design by Martin Görner
European Innovation Academy
 
Exploring MORE Google (Cloud) APIs with Python
Exploring MORE Google (Cloud) APIs with PythonExploring MORE Google (Cloud) APIs with Python
Exploring MORE Google (Cloud) APIs with Python
wesley chun
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
wesley chun
 
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 RICOH THETA x IoT Developers Contest : Cloud API Seminar RICOH THETA x IoT Developers Contest : Cloud API Seminar
RICOH THETA x IoT Developers Contest : Cloud API Seminar
contest-theta360
 
Exploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overviewExploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overview
wesley chun
 
Building and Running Your App in the Cloud
Building and Running Your App in the CloudBuilding and Running Your App in the Cloud
Building and Running Your App in the Cloud
Brandon Minnick, MBA
 
Ad

More from Bruce McPherson (16)

Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databases
Bruce McPherson
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
Bruce McPherson
 
Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilter
Bruce McPherson
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
Bruce McPherson
 
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Bruce McPherson
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Bruce McPherson
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
Bruce McPherson
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a database
Bruce McPherson
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as database
Bruce McPherson
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
Bruce McPherson
 
Google cloud datastore driver for Google Apps Script DB abstraction
Google cloud datastore driver for Google Apps Script DB abstractionGoogle cloud datastore driver for Google Apps Script DB abstraction
Google cloud datastore driver for Google Apps Script DB abstraction
Bruce McPherson
 
Dbabstraction
DbabstractionDbabstraction
Dbabstraction
Bruce McPherson
 
Using script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and ExcelUsing script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and Excel
Bruce McPherson
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
Bruce McPherson
 
VBA API for scriptDB primer
VBA API for scriptDB primerVBA API for scriptDB primer
VBA API for scriptDB primer
Bruce McPherson
 
Javascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBAJavascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBA
Bruce McPherson
 
Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databases
Bruce McPherson
 
Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
Bruce McPherson
 
Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilter
Bruce McPherson
 
Do something in 5 with gas 7-email log
Do something in 5 with gas 7-email logDo something in 5 with gas 7-email log
Do something in 5 with gas 7-email log
Bruce McPherson
 
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Bruce McPherson
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Bruce McPherson
 
Do something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing appDo something in 5 with gas 3-simple invoicing app
Do something in 5 with gas 3-simple invoicing app
Bruce McPherson
 
Do something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a databaseDo something in 5 with gas 2-graduate to a database
Do something in 5 with gas 2-graduate to a database
Bruce McPherson
 
Do something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as databaseDo something in 5 minutes with gas 1-use spreadsheet as database
Do something in 5 minutes with gas 1-use spreadsheet as database
Bruce McPherson
 
Google apps script database abstraction exposed version
Google apps script database abstraction   exposed versionGoogle apps script database abstraction   exposed version
Google apps script database abstraction exposed version
Bruce McPherson
 
Google cloud datastore driver for Google Apps Script DB abstraction
Google cloud datastore driver for Google Apps Script DB abstractionGoogle cloud datastore driver for Google Apps Script DB abstraction
Google cloud datastore driver for Google Apps Script DB abstraction
Bruce McPherson
 
Using script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and ExcelUsing script db as a deaddrop to pass data between GAS, JS and Excel
Using script db as a deaddrop to pass data between GAS, JS and Excel
Bruce McPherson
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
Bruce McPherson
 
VBA API for scriptDB primer
VBA API for scriptDB primerVBA API for scriptDB primer
VBA API for scriptDB primer
Bruce McPherson
 
Javascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBAJavascript like objects and JSON processing in VBA
Javascript like objects and JSON processing in VBA
Bruce McPherson
 
Ad

Recently uploaded (20)

FPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptxFPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptx
ssuser4ef83d
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Classification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptxClassification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptx
wencyjorda88
 
Minions Want to eat presentacion muy linda
Minions Want to eat presentacion muy lindaMinions Want to eat presentacion muy linda
Minions Want to eat presentacion muy linda
CarlaAndradesSoler1
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia
Alexander Romero Arosquipa
 
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
James Francis Paradigm Asset Management
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
DPR_Expert_Recruitment_notice_Revised.pdf
DPR_Expert_Recruitment_notice_Revised.pdfDPR_Expert_Recruitment_notice_Revised.pdf
DPR_Expert_Recruitment_notice_Revised.pdf
inmishra17121973
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..
yuvarajreddy2002
 
Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...
Pixellion
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
FPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptxFPET_Implementation_2_MA to 360 Engage Direct.pptx
FPET_Implementation_2_MA to 360 Engage Direct.pptx
ssuser4ef83d
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Classification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptxClassification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptx
wencyjorda88
 
Minions Want to eat presentacion muy linda
Minions Want to eat presentacion muy lindaMinions Want to eat presentacion muy linda
Minions Want to eat presentacion muy linda
CarlaAndradesSoler1
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
Safety Innovation in Mt. Vernon A Westchester County Model for New Rochelle a...
James Francis Paradigm Asset Management
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
DPR_Expert_Recruitment_notice_Revised.pdf
DPR_Expert_Recruitment_notice_Revised.pdfDPR_Expert_Recruitment_notice_Revised.pdf
DPR_Expert_Recruitment_notice_Revised.pdf
inmishra17121973
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..
yuvarajreddy2002
 
Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...
Pixellion
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 

Goa tutorial

  • 1. OAUTH2 and Apps Script It's not that complicated
  • 2. Authentication and Authorization How to use Goa to simplify OAuth2 user and service account handling in Apps Script. developers console script ide consuming tokens More information at Desktop Liberation Apps Script
  • 3. In the developers console 1. Create the project 2. Select the APIS to use 3. See which scopes the APIS require using the API explorer 4. Get credentials a. Web client - take note of client ID and client secret b. Service Account - download the JSON data to Drive
  • 4. Developers console How to set up an API project in the Google Developers consoleProject dashboard
  • 5. ……. Developers console: 1. Create the project
  • 6. Developers console: 2. Select the APIS to use
  • 7. Developers console: 3. note scopes (API explorer)
  • 8. Developers console: 4a. Get credentials (user) (if using user Oauth2)
  • 9. Developers console: 4b. Get credentials (service) (if using Service account)
  • 10. Apps Script How to set up Goa for OAuth2 and Service Accounts in the Apps Script IDEThe Script IDE
  • 11. In your script 1. Include the cGoa library (MZx5DzNPsYjVyZaR67xXJQai_d-phDA33) 2. Create a one off script to store credentials and run it 3. If a user Oauth2 account (instead of a service account) a. Publish and run your App b. Copy the redirect URI to the developer console from the consent screen c. Allow the consent process to finish 4. Delete your one off script (or move it somewhere private)
  • 12. Script IDE: 1. include cGoa library MZx5DzNPsYjVyZaR67xXJQai_d-phDA33
  • 13. Script IDE: 2a. create credentials script and run it function oneOffScript() { var options = { packageName: 'goa-tutorial-user', clientId: 'xxx.apps.googleusercontent.com', clientSecret:'xxxx', scopes : cGoa.GoaApp.scopesGoogleExpand (['pubsub','cloud-platform']), service:'google' }; // store one off cGoa.GoaApp.setPackage (PropertiesService.getUserProperties(), options); } (if using user Oauth2)
  • 14. function oneOffScript() { var options = { packageName: 'goa-tutorial-service', fileId:'0B92xxxxxxjNDR28', scopes : cGoa.GoaApp.scopesGoogleExpand (['pubsub','cloud-platform']), service:'google_service' }; cGoa.GoaApp.setPackage (PropertiesService.getScriptProperties(), cGoa.GoaApp.createServiceAccount (DriveApp , options)); } Script IDE: 2b. create credentials script and run it (if using Service account) the JSON key file id
  • 15. function doGet(e) { var goa = cGoa.GoaApp.createGoa ('goa-tutorial-user', PropertiesService.getUserProperties()).execute (e); if (goa.needsConsent()) { return goa.getConsent(); } return HtmlService.createHtmlOutput (goa.hasToken() ? 'your token has been stored' : 'failed to get token') .setSandboxMode(HtmlService.SandboxMode.IFRAME); } Script IDE: 3a. Publish app and run it (if using user Oauth2)
  • 16. Script IDE: 3b. Copy redirect uri and origin to console (if using user Oauth2)
  • 17. Script IDE: 3c. Allow the consent process to complete (if using user Oauth2)
  • 18. function oneOffScript() { …. } function doGet() { …. } Script IDE: 4. delete one off script (and doGet) scripts no longer needed
  • 19. Apps Script How to consume Goa access tokens in Apps Script projects Using the token
  • 20. Using Goa 1. Once Goa has been set up there is no need for any more interaction 2. Just fetch the access token and use it. It will be automatically refreshed
  • 21. Using Goa: 1. Getting the token var goa = cGoa.GoaApp.createGoa ('goa-tutorial-user', PropertiesService.getUserProperties()).execute (); if (goa.hasToken()) { var token = goa.getToken(); } same for both service account and user OAuth2 Just change property store and credentials name
  • 22. Using Goa: 2. Using the token var result = UrlFetchApp.fetch (apiUrl , { header: { authentication: 'Bearer ' + goa.getToken() } }); same for both service account and user OAuth2
  • 23. More Goa The source code, examples and additional features of Goa, including how to set up for API providers other than Google can be found at Desktop Liberation Further capabilities