本文介绍了Google云端硬盘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

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

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云端硬盘API消息“超出了未经身份验证的使用的每日限制".在查看来自Salesforce的文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 15:17