【发布时间】:2020-08-15 18:02:26
【问题描述】:
我想在 swift 上将我的 iOS 应用与 Google Classroom 相关联。我目前的目标是能够获得我注册的所有课程的列表。
这是我目前使用的代码
func googleClassroomList() {
//let sharedInstance = GIDSignIn.sharedInstance()
//let handler = sharedInstance
googleClassroomService.apiKey = "AIzaSyBOGamjhRuu45T2jT7Qa3LmtntSwgIxeqo"
let query = GTLRClassroomQuery_CoursesList.query()
query.pageSize = 1000
let classQuery = googleClassroomService.executeQuery(query, completionHandler: { ticket , fileList, error in
if error != nil {
let message = "Error: \(error?.localizedDescription ?? "")"
print(message)
} else {
if let list = fileList as? GTLRClassroomQuery_CoursesList {
self.fileList = list
print("List: \(list)")
}
else {
print("Error: response is not a file list")
}
}
}
)
}
这是错误信息:
Error: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
我不明白我在哪里附加了 OAuth 访问令牌,我尝试将它放在 apiKey 下,但我真的不明白我应该做什么。作为参考,我正在使用此身份验证范围。 “https://www.googleapis.com/auth/classroom.courses”
【问题讨论】:
标签: swift rest google-api google-classroom