Skip to content

An open source plugin for Instructure Canvas to connect to Google Drive.

License

Notifications You must be signed in to change notification settings

learningtapestry/canvas-google-drive-connector

Repository files navigation

Known Vulnerabilities

CanvasLMS / GoogleDrive integration

Simple LTI app for providing google-drive integration into CanvasLMS

Features:

  • allow educators to link/embed gdrive files into course content
  • allow students send gdrive files as part of assignment

Getting Started

This app uses:

  • Ruby 2.5.0 + Sinatra
  • PostgreSQL 9.6
  • Redis
  1. Create a Google app on the Google Developer Console.

  2. Enable access to the Drive API for the newly created Google app

  3. Create credentials for accessing the Google app

  • When asked where you will be calling the API from, select "Web server"
  • When asked what data you will be accessing, select "User data"
  • Under "Authorized Javascript origins" enter the URL where this app is deployed
  • Under "Authorized redirect URIs" enter the same URL as above, with /google-auth/callback at the end

This will give you the OAuth2 credentials to be used in this app to access the Google app.

  1. Go to the "Domain verification" tab and verify the domain this app is running on.

To configure this app with your new credentials, first create your .env file by running cp .env.template .env and then modify with your new Google credentials:

SESSION_SECRET=[Generate a string here with SecureRandom.hex(32)]
GOOGLE_KEY=[Your Google client ID]
GOOGLE_SECRET=[Your Google client secret]

Install dependencies and create the database:

bundle install
bundle exec rake db:create db:migrate

For deploying (not development) you should also precompile assets: bundle exec rake assets:clean assets:precompile

Run

For running the server: ruby app.rb

you can have an interactive console with the app configured and imported, using: bundle exec rake console

Launching from Canvas LMS

To launch the Google Drive Connector app from a Canvas instance, see this wiki:

https://github.com/learningtapestry/canvas-google-drive-connector/wiki/Configuring-the-LTI-application

tests

uses Rspec: bundle exec rspec

you can check the coverage report on coverage/index.html

API

Config

  • / [GET]

    • simple root endpoint (used mostly for smoke testing)
    • response: plain/text with the project name
  • /config.xml [GET]

    • The LTI app configuration inside canvas is done via an XML document using the IMS Common Cartridge specification
    • https://www.imsglobal.org/cc/index.html.
    • response: application/xml with the config.

Credentials management

  • /credentials/new [GET]

    • render new credentials form
  • /credentials [POST]

    • build new credentials pair and return to the user

Google Oauth2

used internally

  • /google-auth [GET]

    • Redirect to Google's authorization page if we don't have the credentials yet.
  • /google-auth/callback [GET]

    • handle the callback from google after authorization

LTI endpoints

All LTI launch requests are done via POST

  • /lti/gdrive-list [POST]

    • Renders a google drive list.
    • This action is used internally on XHR requests, after we've accessed a LTI launch url.
    • authentication: session user, google credentials and csrf token
    • Params:
      • folder_id : list the contents of this folder
      • search_term : term to search on the user's drive file names
      • action : which kind of action should be enabled when a file is selected
  • /lti/course-navigation [POST]

  • /lti/editor-selection [POST]

    • Launch url for editor selection (button inside the rich-text editor fields)
    • The select action shows the options for link or embed the file in the content.
    • authentication: lti request and google credentials
    • Params: LTI Launch (http://www.imsglobal.org/specs/ltiv1p0/implementation-guide) from Canvas
  • /lti/resource-selection [POST]

  • /lti/link-selection [POST]

    • Launch url for resource selection (module -> add item -> external tool)
    • The link_resource action generate a lti-link for the resource selected.
    • authentication: lti request and google credentials
    • resource-selection and link-selection are the same.
    • Params: LTI Launch (http://www.imsglobal.org/specs/ltiv1p0/implementation-guide) from Canvas
  • /lti/resources/:file_id [POST]

  • /lti/homework-submission [POST]

  • /lti/documents [POST]

    • Generate an HTML snapshot of the google drive document
    • authentication: session user, google credentials and csrf token
    • Params:
      • file_id : the gdrive file id
  • /lti/documents/:file_id [POST]

LICENSE

This project is licensed under GPL3

About

An open source plugin for Instructure Canvas to connect to Google Drive.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published