Google Drive API 消息“已超出未经身份验证的使用的每日限制".从 Salesforce 查看文件时 [英] Google Drive API message "Daily Limit for Unauthenticated Use Exceeded." while viewing files from Salesforce

查看:35
本文介绍了Google Drive API 消息“已超出未经身份验证的使用的每日限制".从 Salesforce 查看文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I created a service account, got json configuration file and I request an access token using it. The response is ok, I receive token. When I upload file using it everything is ok, but when I try to view files from a folder it returns error message

已超出未经身份验证的使用的每日限制.继续使用需要注册.

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

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

My service account only needs to access own files, it doesn't access files of any other users. My code for viewing files (right now I try to debug the response):

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;
}

推荐答案

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

I found out what was the problem. I was sending access token in the url address instead of in the header. Eventually I did it like this:

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;
}

这篇关于Google Drive API 消息“已超出未经身份验证的使用的每日限制".从 Salesforce 查看文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆