我尝试从the documentation添加courseWork,但它显示Request has insufficient authentication scopes
错误。
范围是here
我试过了:
from __future__ import print_function
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
store = file.Storage('credentials.json')
creds = store.get()
SCOPES = 'https://www.googleapis.com/auth/classroom.coursework.students'
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('classroom', 'v1', http=creds.authorize(Http()))
courseWork = {
'title': 'Ant colonies',
'description': 'Read the article about ant colonies and complete the quiz.',
'materials': [
{'link': { 'url': 'http://example.com/ant-colonies' }},
{'link': { 'url': 'http://example.com/ant-quiz' }}
],
'workType': 'ASSIGNMENT',
'state': 'PUBLISHED',
}
courseWork = service.courses().courseWork().create(courseId='105332016379', body=courseWork).execute()
print('Assignment created with ID {0}'.format(courseWork.get('id')))
错误显示如下:
那么解决方案是什么?