使用“https://www.googleapis.com/auth/drive”范围时出错

时间:2013-03-08 09:09:01

标签: oauth-2.0 google-drive-api google-oauth

google-api-java-client的版本: 谷歌的API-1.13.2-beta.jar Java环境: Java 6

描述问题。

我有一个问题。 我想使用OAuth 2.0 for Devices访问Google云端硬盘。 使用"https://www.googleapis.com/auth/drive"范围是错误的。 在范围内使用"https://docs.google.com/feeds/"时,我成功了。 我想知道我是否使用"https://docs.google.com/feeds/"来使用“DriveAPI”I。 这是正确的用法吗?

请求

POST https://accounts.google.com/o/oauth2/device/code HTTP/1.1

client_id=xxxxx.apps.googleusercontent.com&scope=https://www.googleapis.com/auth/drive

Response: {   "error" : "invalid_scope" }

响应:

POST https://accounts.google.com/o/oauth2/device/code HTTP/1.1

client_id=xxxxx.apps.googleusercontent.com&scope=https://docs.google.com/feeds/

Response:
{
  "device_code" : "4/e6HcZHKPz-eExgLb_Ll9V8qoT1NP",
  "user_code" : "zzwiv48b",
  "verification_url" : "http://www.google.com/device",
  "expires_in" : 1800,
  "interval" : 5
}

您希望如何修复它? 我认为可以在“https://www.googleapis.com/auth/drive”我的范围内进行身份验证。

developers.google.com

stackoverflow.com

3 个答案:

答案 0 :(得分:2)

你在协议中缺少一个h。尝试 https://docs.google.com/feeds/ ,而不是 ttps://docs.google.com/feeds/ 。对所有范围网址应用相同的更改

答案 1 :(得分:0)

我有完全相同的问题。 我已按照开发文档中的说明操作,并使用“www.googleapis.com/auth/drive”作为请求中的范围。 最后,我在回复中得到了“invalid_scope”。

所以我尝试使用“www.googleapis.com/auth/devstorage.full_control”作为范围,它有效!提示来自:https://cloud.google.com/storage/docs/authentication#oauth

BUT !!当我使用我创建的访问令牌列出谷歌驱动器帐户信息时,我收到错误代码403,消息是“权限不足”。

这是我以前申请帐户信息的原因: curl -H“授权:Bearer $ ACCESS_TOKEN”https://www.googleapis.com/drive/v2/about?key= $ APP_KEY

这让我很困惑......

答案 2 :(得分:0)

来自Google文档“使用OAuth 2.0 for Devices”(https://developers.google.com/identity/protocols/OAuth2ForDevices#allowedscopes):

  

对设备使用OAuth 2.0流时,只能访问以下范围:

     
      
  • Analytics配置和报告API
  •   
  • 日历API
  •   
  • 通讯录API
  •   
  • 云打印API
  •   
  • 云端存储API
  •   
  • Fitness REST API
  •   
  • Fusion Tables API
  •   
  • Google登录
  •   
  • YouTube数据和直播API
  •   

我在此列表中看不到Drive API,我认为这是“invalid_scope”错误的原因

相关问题