Google 在查看来自 Salesforce 的文件时驱动 API 消息 "Daily Limit for Unauthenticated Use Exceeded."

Google Drive API message "Daily Limit for Unauthenticated Use Exceeded." while viewing files from Salesforce

我创建了一个服务帐户,获得了 json 配置文件,并使用它请求了一个访问令牌。响应正常,我收到令牌。当我使用它上传文件时一切正常,但是当我尝试从文件夹中查看文件时它 returns 错误消息

Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.

我的服务帐户只需要访问自己的文件,它不会访问任何其他用户的文件。 我查看文件的代码(现在我尝试调试响应):

public List<String> getFilesList() {
    Http http = new Http();
    HttpRequest req = new HttpRequest();
    req.setMethod('GET');
    req.setEndpoint('https://www.googleapis.com/drive/v2/files?accessToken='+accessToken');
    HttpResponse resp = http.send(req);
    System.debug(resp);
    System.debug(resp.getBody());
    return null;
}

对于错误 Daily Limit for Unauthenticated Use Exceeded. Continued use requires sign,请尝试在 APIs 下检查您的 Google 开发者控制台,即与 API 键关联的项目。示例:https://console.developers.google.com/project/<your app id>/apiui/api。确保 Google+API 的状态设置为 ON。

根据此 SO question,该错误表明您尚未设置 Google APIs 控制台项目。

  1. Create a Google APIs Console project
  2. On the Services pane, enable all of the APIs that your project requires.
  3. On the API Access pane, click Create an OAuth 2.0 client ID. A dialog opens. Fill in your project's information. Click Next
  4. Choose the appropriate application type. Based on the tags you used for this post, I am guessing this is an iOS project so select Installed application.
  5. Enter your bundle ID. You don't need to enter an App Store ID until your app is listed there.
  6. Click Create Client ID.

You will see the client ID and client secret values. You will use these values to enable communication with your project and the Google APIs.

If you aren't already using it, see the Google+ iOS SDK and documentation for a full walk through. The task called "write moments" is similar in implementation and demonstrates how to connect to and use the Google+ REST APIs from within an iOS project that uses the SDK.

You'll need to specify the scope of plus.me to get the profile information.

希望对您有所帮助!

我发现了问题所在。我在 url 地址而不是 header 中发送访问令牌。最终我是这样做的:

public List<String> getFilesList() {
 Http http = new Http();
 HttpRequest req = new HttpRequest();
 req.setMethod('GET');
 req.setEndpoint('https://www.googleapis.com/drive/v2/files);
 req.setHeader('Authorization', 'Bearer '+accessToken);
 HttpResponse resp = http.send(req);
 return null;
}