本文介绍了我如何使用谷歌驱动的API键从Android应用程序访问驱动器的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法访问谷歌驱动器。我创建了谷歌API控制台的API密钥,并启用了谷歌驱动器的API和SDK。我在哪里设置code的API KEY?

驱动器制造商没有一个 setJsonHtt prequestInitializer 方法。我在哪里可以设置KEY?是否有替代品?

 专用驱动器getDriveService(字符串标记){

HttpTransport HT = AndroidHttp.newCompatibleTransport();
JacksonFactory jsonFactory =新JacksonFactory();
凭据凭据=新GoogleCredential()setAccessToken(标记)。

    Drive.Builder B =新Drive.Builder(HT,jsonFactory,证书);
    b.setHtt prequestInitializer(凭证);

返回b.build();
}
 

入门:

  com.google.api.client.googleapis.json.GoogleJsonResponseException:403禁止
 {
   code:403,
   错误:[{
     域:usageLimits
     消息:访问未配置,
     原因:accessNotConfigured
  }],
  消息:访问未配置
 }
 

解决方案

您需要激活两件事情在API控制台: - 驱动器API - 驱动器的SDK

很多人只有一个激活。

此外,不要忘了释放最后的应用程序之前添加真实的证书SHA1。

有这样类似的回答:谷歌驱动器SDK异常

I can't access Google drive. I created an API KEY in Google API console and enabled Google Drive API and SDK. Where do I set that API KEY in code?

Drive builder does not have a setJsonHttpRequestInitializer method. Where can I set the KEY?Is there alternatives?

private Drive getDriveService(String token) {

HttpTransport ht = AndroidHttp.newCompatibleTransport();
JacksonFactory jsonFactory = new JacksonFactory();
Credential credentials = new GoogleCredential().setAccessToken(token);

    Drive.Builder b = new Drive.Builder(ht, jsonFactory, credentials);
    b.setHttpRequestInitializer(credentials);

return b.build();
}

Getting:

 com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
 {
   "code" : 403,
   "errors" : [ {
     "domain" : "usageLimits",
     "message" : "Access Not Configured",
     "reason" : "accessNotConfigured"
  } ],
  "message" : "Access Not Configured"
 }
解决方案

You need to activate TWO things in the API console:- Drive API- Drive SDK

Many people activate only one.

Moreover, don't forget to add your real certificate SHA1 before releasing the final application.

There is this similar answer:Google Drive SDK Exception

这篇关于我如何使用谷歌驱动的API键从Android应用程序访问驱动器的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 01:16