4848# OAuth Consent Screen: https://console.cloud.google.com/apis/credentials/consent
4949SCOPES = [
5050 "https://www.googleapis.com/auth/userinfo.profile" ,
51- "https://www.googleapis.com/auth/userinfo.email" ,
52- "https://www.googleapis.com/auth/classroom.courses.readonly" ,
53- "https://www.googleapis.com/auth/classroom.addons.student" ,
54- "https://www.googleapis.com/auth/classroom.addons.teacher" ,
51+ "https://www.googleapis.com/auth/userinfo.email"
5552]
56- CLASSROOM_API_SERVICE_NAME = "classroom"
57- CLASSROOM_API_VERSION = "v1"
58-
59- # An API key in your GCP project's credentials:
60- # https://console.cloud.google.com/apis/credentials.
61- GOOGLE_API_KEY = os .environ .get ("GOOGLE_API_KEY" )
6253
6354# Point to a database file in the project root.
6455DATABASE_FILE_NAME = os .path .join (os .path .abspath (os .path .dirname (__file__ )),
@@ -180,7 +171,7 @@ def test_api_request(request_type="username"):
180171 Tests an API request, rendering the result in the "show-api-query-result.html" template.
181172
182173 Args:
183- request_type: The type of API request to test. Can be "username" or "courses" .
174+ request_type: The type of API request to test. Currently only "username" is supported .
184175 """
185176
186177 if "credentials" not in flask .session :
@@ -203,26 +194,14 @@ def test_api_request(request_type="username"):
203194
204195 fetched_data = flask .session .get ("username" )
205196
206- elif request_type == "courses" :
207- classroom_service = googleapiclient .discovery .build (
208- CLASSROOM_API_SERVICE_NAME ,
209- CLASSROOM_API_VERSION ,
210- credentials = credentials ,
211- discoveryServiceUrl =
212- f"https://classroom.googleapis.com/$discovery/rest?labels=ADD_ONS_ALPHA&key={ GOOGLE_API_KEY } "
213- )
214-
215- fetched_data = classroom_service .courses ().list (
216- pageSize = 10 ).execute ().get ("courses" , [])
217-
218197 # Save credentials in case access token was refreshed.
219198 flask .session ["credentials" ] = credentials_to_dict (credentials )
220199 save_user_credentials (credentials )
221200
222201 # Render the results of the API call.
223202 return flask .render_template (
224203 "show-api-query-result.html" ,
225- data = json .dumps (fetched_data , indent = 2 ), #flask.jsonify(courses),
204+ data = json .dumps (fetched_data , indent = 2 ),
226205 data_title = request_type )
227206
228207
@@ -384,6 +363,7 @@ def save_user_credentials(credentials=None, user_info=None):
384363
385364 existing_user = get_credentials_from_storage (
386365 flask .session .get ("login_hint" ))
366+
387367 if existing_user :
388368 if user_info :
389369 existing_user .id = user_info .get ("id" )
0 commit comments