GCR Materials is a Python script that empowers you to efficiently retrieve and download course materials from Google Classroom using the Google Classroom API and Google Drive API. This tool is especially useful for fetching materials from multiple courses and organizing them into individual folders.
-
Clone the Repository: Begin by cloning this repository to your local machine.
-
Google OAuth Consent Screen Setup:
In order for GCR Materials to access your Google Classroom and Google Drive data securely, you need to set up a Google OAuth consent screen. This process involves configuring how the script interacts with your Google account. Follow these steps:
-
2.1. Create a Project:
- Go to the Google Cloud Console.
- Create a new project or select an existing project by clicking on the project dropdown at the top of the screen and selecting "New Project" or an existing project.
-
2.2. Enable the Required APIs:
- In the left sidebar, click on "APIs & Services" > "Library."
- Search for "Google Classroom API" and "Google Drive API" one by one.
- Enable both APIs for your project.
-
2.3. Configure OAuth Consent Screen:
- In the left sidebar, click on "APIs & Services" > "OAuth consent screen."
- Choose "External" or "Internal" user type based on your needs.
- Fill in the required fields such as "Application name" and "Support email."
- Under "Scopes for Google APIs," add the following scopes:
https://www.googleapis.com/auth/classroom.courses.readonlyhttps://www.googleapis.com/auth/classroom.courseworkmaterials.readonlyhttps://www.googleapis.com/auth/drive.readonly
-
2.4. Create Credentials:
- After configuring the OAuth consent screen, go to "APIs & Services" > "Credentials."
- Click on the "Create Credentials" button and select "OAuth client ID."
- Choose "Desktop app" as the application type.
- Provide a name for the OAuth client ID.
- Click "Create."
- You will see a message saying "To create an OAuth client ID, you must first set a product name on the Consent screen."
- Click "Configure consent screen" and select the product name you set in the previous step.
- Click "Save" and go back to the credentials page.
-
2.5. Download Credentials JSON:
- On the credentials page, click the download icon next to the created OAuth client ID. This will download a JSON file containing your credentials.
- Rename the downloaded JSON file to
credentials.json.
-
-
Place Credentials File: Move the
credentials.jsonfile you obtained in the previous step to the root directory of the cloned repository.
Run the script using the following command in your terminal:
python gcr.pyThis will download all the active courses' materials into the current directory.
-
--course: Fetch and download materials for a specific course:
python gcr.py --course 'course-name' -
--courses: Fetch and download materials for multiple courses listed in a text file split by lines:
python gcr.py --courses 'path/to/courses.txt' -
--download-path: Specify the download path for the materials. If not provided, materials will be downloaded in the current directory:
python gcr.py --download-path 'path/to/download/at'
Contributions to GCR Materials are welcome! If you have improvements, bug fixes, or new features to propose, please open an issue first to discuss the changes.
GCR Materials is open-source and licensed under the MIT License.