I am trying to make a discord bot that interacts with the google API specifically the Google Classroom API, so therefore I made a new project from the google console and created a new OAuth client for a web application. I enabled the Classroom API as well and selected all the scopes that I wanted to use:
['https://www.googleapis.com/auth/classroom.course-work.readonly',
'https://www.googleapis.com/auth/classroom.student-submissions.students.readonly',
'https://www.googleapis.com/auth/classroom.courses.readonly']
Then I set up my python programme using Google's example (At first I wrote my own using the documentation but got the same result). When I run the example code everything goes fine, it opens the browser and asks me to select my account, I select my school account and when it loads and I expect an Authorization screen to pup up to ask me if I allow the requested data it says something went wrong with no error messages at all. I have downloaded the correct credentials.json folder from the google dashboard and used it in my programme.
I will also provide the simplified code that I wrote maybe it's a problem there.
import pickle
import os
from google_auth_oauthlib.flow import Flow, InstalledAppFlow
from googleapiclient.discovery import build
from google.auth.transport.requests import Request
CLIENTSECRETPATH = "credentials.json"
APISERVICENAME = "classroom"
APIVERSION = "v1"
SCOPES = ['https://www.googleapis.com/auth/classroom.course-work.readonly', 'https://www.googleapis.com/auth/classroom.student-submissions.students.readonly', 'https://www.googleapis.com/auth/classroom.courses.readonly']
cred = None
if os.path.exists("toke.pickle"):
with open("tiken.pickle", "rb") as token:
cred = pickle.load(token)
if not cred or not cred.valid:
if cred and cred.expired and cred.refresh_token:
cred.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(CLIENTSECRETPATH, SCOPES)
cred = flow.run_local_server()
with open("token.pickle", "wb") as token:
pickle.dump(cred, token)
try:
service = build(APISERVICENAME, APIVERSION, credentials=cred)
except Exception as e:
print(e)
Edit: I tried to change some settings on the google console and randomly decided to click publish as the project was still in the testing state, after doing this I could sign in with no errors. But that still doesn't explain why it didn't work when it was in a testing status, I added my school e-mail address to the test users list and made sure I did everything right for testing.