This app is an example of the integration between Google App Scripts and Weekdone tool providing authorization with OAuth2 protocol.
This is an example of a way to use OAuth2 authorization with Google App Scripts. You could change this code to any other third-party service that provides OAuth2 authorization.
-
Create a new Google Sheet and navigate to Tools > Script editor
-
Get your
script_id
from Google App Script at File > Project properties -
Go to your Weekdone account and create a new app at Company Settings > Applications
-
Define a name for your app and input the Redirect URI below replacing the
{your_script_id}
to yourscript_id
from step 2: https://script.google.com/macros/d/{your_script_id}/usercallback -
Create your app and get your
client_id
andclient_secret
credentials -
On your Google App Script, create the files according to this repo and replace the credentials at file
credentials.gs
with the ones that you got on the previous step -
Go back to your Google Sheet and refresh the page. Your integration with Weekdone is settled!
-
Click on Weekdone Integration > Login to authorize with your Weekdone credentials
-
Click on Weekdone Integration > Retrieve Objectives to get data from your Weekdone account
The OAuth2
authorization is executed by auth.gs
file, following the original documentation at OAuth2 for Apps Script
The onOpen()
function is a trigger that automatically runs when a Google Document is open.
This function creates a new menu that allow users to login and authenticate at third-party services.
If you want to add more services at the integration that you are using, you could add new items at the menu, like Retrieve Objectives
.
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Weekdone Integration')
.addItem('Login', 'showSidebar')
.addItem('Retrieve Objectives', 'getObjectives')
.addItem('Logout', 'logout')
.addToUi();
showDialog();
}
Add your requests to your third-party services to the requests.gs
file. You also could set the APIs URLs at your credentials.gs
file.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This application is a demonstration of how to use OAuth2 protocol authorization with Google App Scripts that allows to integrate with any other service through Open APIs.