Skip to content

Reference implementation of a Google Classroom add-on, written in Python and broken into steps corresponding to a walkthrough tutorial https://developers.google.com/classroom/add-ons/walkthroughs/walkthroughs-overview.

License

Notifications You must be signed in to change notification settings

googleworkspace/python-classroom-addon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Classroom add-ons Python Examples

This project hosts web applications that demonstrate the implmentation of a Google Classroom add-on using Python. Current examples use the Flask framework.

Documentation

These examples are intended to accompany the guided walkthroughs on the Classroom Add-ons developer site. Please refer to the site for implementation details.

Requirements

  • Python 3.7+

Project Setup

  1. Create a Google Cloud Platform (GCP) project. Enable the following in the API Library:

    Visit the developer site for configuration instructions for the GWM SDK. You will also need to install the add-on for it to be visible in Google Classroom.

  2. Visit your project's Credentials page. Create two credentials in the project:

    • An API Key. You can leave it as Unrestricted for the purposes of these examples.
    • An OAuth client ID.
      • The application type should be Web application.
      • Add <your server>/callback as an Authorized redirect URI. For example, https://localhost:5000/callback

    Return to the Credentials page once both have been created, then:

    • Copy your API Key and assign it to the environment variable GOOGLE_API_KEY:
      export GOOGLE_API_KEY=YOUR_COPIED_API_KEY
    • Download the OAuth2 client credentials as JSON.
  3. Install Python 3.7+ and ensure that pip is available:

    python -m ensurepip --upgrade
    
  4. Clone this repository and cd into the root project directory:

    git clone https://github.com/googleworkspace/python-classroom-addon
    cd python-classroom-addon
    
  5. (Optional, but recommended!) Set up and activate a new Python virtual environment in the python-classroom-addon directory:

    python3 -m venv .classroom-addon-env
    source .classroom-addon-env/bin/activate
    

    When finished, use the deactivate command in your shell to exit the virtual environment.

  6. cd into an example directory:

    cd flask/01-basic-app
    
  7. Install the required libraries using pip:

    pip install -r requirements.txt
    
  8. Inspect the main.py file and enable one option for running a server. For example, to run the web app on localhost:

    if __name__ == "__main__":
        ### OPTION 1: Unsecured localhost
        os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
    
        # Run the application on http://localhost:5000.
        app.run(debug=True)
  9. Launch the server by running the main.py file:

    python main.py
    
  10. To load your app, either open the app in your browser or select your application in the Add-ons menu when creating an Assignment in Google Classroom.

Useful Resources

Authors

About

Reference implementation of a Google Classroom add-on, written in Python and broken into steps corresponding to a walkthrough tutorial https://developers.google.com/classroom/add-ons/walkthroughs/walkthroughs-overview.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published