Introduction
In order to access data in Google Classroom and Google Calendar, Swotly requires a service account within a school's Google workspace.
A service account is a special type of account intended to represent a non-human user that needs to authenticate and be authorised to access data in Google APIs. A service account can run as a privileged user or it can be locked down only to perform certain actions.
This article explains how an administrator should create a service account for Swotly that provides read-only access to courses, topics, coursework and calendar events.
Steps
1. Create a project
- Sign in to the Google Cloud Console as an Administrator
- Create a new project
- If you haven't used the console before, agree to the Terms of Service and click Create Project
- If you have used the console before, click the projects drop-down list then click New Project
- Enter Swotly as the project name and click Create
- Wait until the project is created
- Ensure Swotly is selected in the projects drop-down list
2. Enable the APIs
- Click the burger-bar button in the top-left to expand the menu
- Navigate to APIs & Services
- Click Enable APIs and Services
- For each API in the table below
- Search for it by name
- Click to view it
- Click Enable
API Google Classroom API Google Calendar API
Tip: To enable the second API, click Left-Button to go back, then click Enable APIs and Services again
3. Create the service account
- Click the burger-bar button in the top-left to expand the menu
- Navigate to IAM & Admin > Service Accounts
- Click Create Service Account
- Enter Swotly Service Account as the service account name
- Optionally, enter a description
- Click Done
- Wait until the service account is created
- Click the Email for the service account; it should begin swotly-service-account
- Take note of the Unique ID as you will need it in the following steps
- Click the Keys tab
- Click Add Key
- Select Create new key
- Select JSON as the Key Type
- Click Create.
- Wait until you see the message "Private key saved to your computer"
- You should see a message within your browser that a JSON file has been downloaded to your computer
- Take note of the name and location of this file as you will need it later
- Click Close
4. Manage service account permissions
-
- Sign in to the Google Admin Console as an Administrator
- Click the burger-bar button in the top-left to expand the menu
- Navigate to Security > Access and data control > API controls
- Click Manage Domain-Wide Delegation
- Click Add new
- Enter the Client ID from Step 3
- Add each of the scopes from the table below into the OAuth scopes, separated by a comma. Alternatively, copy the full list from here and paste it into the OAuth scopes
Scope https://www.googleapis.com/auth/classroom.courses.readonly https://www.googleapis.com/auth/classroom.topics.readonly https://www.googleapis.com/auth/classroom.rosters.readonly https://www.googleapis.com/auth/classroom.coursework.students.readonly https://www.googleapis.com/auth/classroom.student-submissions.students.readonly https://www.googleapis.com/auth/calendar.events.readonly - Click Authorise
5. Provide the Service Account details
- Email the JSON file you downloaded in Step 3 to support@swotly.io
- Delete the file from your local machine