Skip to content

Example of the use of OAuth2 protocol with third-party services in Google App Scripts

License

Notifications You must be signed in to change notification settings

icmaia90/oauth2-google-app-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weekdone with Google App Script

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.

Installation

  1. Create a new Google Sheet and navigate to Tools > Script editor

  2. Get your script_id from Google App Script at File > Project properties Screen

  3. Go to your Weekdone account and create a new app at Company Settings > Applications screen 1

  4. Define a name for your app and input the Redirect URI below replacing the {your_script_id} to your script_id from step 2: https://script.google.com/macros/d/{your_script_id}/usercallback

  5. Create your app and get your client_id and client_secret credentials Screen

  6. 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 Screen

  7. Go back to your Google Sheet and refresh the page. Your integration with Weekdone is settled!

  8. Click on Weekdone Integration > Login to authorize with your Weekdone credentials Screen

  9. Click on Weekdone Integration > Retrieve Objectives to get data from your Weekdone account Screen

Usage

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.

Contributing

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.

License

GNU General Public License v3.0

About

Example of the use of OAuth2 protocol with third-party services in Google App Scripts

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published