我想通過 HTTP 請求從受眾那里獲取課程串列,我已經在 Google Cloud 中的專案中設定了所需區域,但是當我嘗試獲取課程時仍然出現錯誤。
PS - 請不要向我提供檔案和庫,不要試圖說服我,我只需要一個 HTTP 請求。
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"status": "PERMISSION_DENIED",
"details": [{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_SCOPE_INSUFFICIENT",
"domain": "googleapis.com",
"metadata": {
"method": "google.classroom.v1.Courses.ListCourses",
"service": "classroom.googleapis.com"
}
}]
}
}
我嘗試添加?scope=https://www.googleapis.com/auth/classroom.courses.readonly 到鏈接的末尾這是請求模板
curl \
'https://classroom.googleapis.com/v1/courses?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
uj5u.com熱心網友回復:
我將假設您正在使用
所以在你的情況下錯誤Request had insufficient authentication scopes。意味著當您請求授權時,您沒有請求上述范圍之一。您的訪問令牌沒有足夠的授權范圍來發出請求。
解決方案是使用相關方法所需的范圍之一重新授權您的用戶。
您可以在Using OAuth 2.0 to Access Google APIs中閱讀有關如何請求授權以及范圍是什么的更多資訊檔案頁面
提示:您在 oauth2 流程中的第一個包含范圍。
https://accounts.google.com/o/oauth2/v2/auth?scope=https://www.googleapis.com/auth/classroom.courses&response_type=code&redirect_uri=http://127.0.0.1:9004&client_id=client_id
該視頻可能會幫助您了解范圍使用 curl 了解 Google OAuth 2.0,因為您似乎正在使用 curl 而不僅僅是原始 HTTP 呼叫。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/525323.html
