我想在Go中編寫一個簡單的命令行Google Drive api。在我看來,到目前爲止,我已經成功地驗證了應用程序,因爲我可以獲取access_token和refresh_token。在問題發生時,我嘗試使用令牌訪問SDK API,我得到了以下錯誤消息超出未經驗證的使用的每日限制
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
}
我注意到另一個奇怪的是,我沒有看到我的谷歌API控制檯的任何配額信息。所以不知道這是否是問題。但由於我可以被認證,所以我想我應該罰款控制檯API設置。
下面是該API查詢
accessUrl := "https://www.googleapis.com/drive/v2/files" + "?access_token=\"" + accessToken + "\""
if res , err := http.Get(accessUrl); err == nil {
if b, err2 := ioutil.ReadAll(res.Body); err2 == nil {
fmt.Println(string(b))
}else{
fmt.Println(err2)
}
}else{
fmt.Println(err)
}
好吧,我設法解決了這個問題。看起來我和許多其他人犯了同樣的錯誤。我忘了在API控制檯中啓用「Drive API」。一旦我做到了,那麼它工作得很好。錯誤信息是真的令人誤解。我希望這可以幫助某人解決方案的tnx – tabiul
,它有幫助! :) –
Drive API在哪裏?我如何啓用? – sureshvv