android-YouTube API:com.google.api.client.googleapis.json.GoogleJsonResponseException:禁止使用403

我是YouTube API的新手.我已经从Eclipse的github下载并导入了yt-direct-lite youtube android项目.一切顺利.但是,当我运行该项目时,它会吐出/弹出以下错误消息:

[Error] Access not configured: The API (youTube Data API) is not enabled for your project. Please use google developer console to update your configuration.

但是,我已经打开了Google API以及YouTube Data API v3.

另外,我已经生成了API密钥.一切都很好,但是要登录该项目中的Google / Gmail帐户.同样,在异常以下触发.

02-04 15:06:38.553: E/TetsProject(8413): Error
02-04 15:06:38.553: E/TetsProject(8413): com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
02-04 15:06:38.553: E/TetsProject(8413): {
02-04 15:06:38.553: E/TetsProject(8413):   "code": 403,
02-04 15:06:38.553: E/TetsProject(8413):   "errors": [
02-04 15:06:38.553: E/TetsProject(8413):     {
02-04 15:06:38.553: E/TetsProject(8413):       "domain": "usageLimits",
02-04 15:06:38.553: E/TetsProject(8413):       "message": "Access Not Configured. The API (YouTube Data API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
02-04 15:06:38.553: E/TetsProject(8413):       "reason": "accessNotConfigured",
02-04 15:06:38.553: E/TetsProject(8413):       "extendedHelp": "https://console.developers.google.com"
02-04 15:06:38.553: E/TetsProject(8413):     }
02-04 15:06:38.553: E/TetsProject(8413):   ],
02-04 15:06:38.553: E/TetsProject(8413):   "message": "Access Not Configured. The API (YouTube Data API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
02-04 15:06:38.553: E/TetsProject(8413): }
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:312)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1049)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.ytdl.MainActivity$3.doInBackground(MainActivity.java:417)
02-04 15:06:38.553: E/TetsProject(8413):    at com.google.ytdl.MainActivity$3.doInBackground(MainActivity.java:1)
02-04 15:06:38.553: E/TetsProject(8413):    at android.os.AsyncTask$2.call(AsyncTask.java:287)
02-04 15:06:38.553: E/TetsProject(8413):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
02-04 15:06:38.553: E/TetsProject(8413):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
02-04 15:06:38.553: E/TetsProject(8413):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
02-04 15:06:38.553: E/TetsProject(8413):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
02-04 15:06:38.553: E/TetsProject(8413):    at java.lang.Thread.run(Thread.java:856)
02-04 15:06:38.633: I/brcm-gr(8413): [gralloc_lock]: new usage 0x933

我不知道这是怎么回事?

解决方法:

经过一些RnD,我已经解决了这个问题.事情是第一
启用youtubeapi v3和google api,然后转到凭据,然后生成Android API密钥.

首先通过单击“创建新的客户端ID”来生成客户端ID
然后选择已安装的应用程序,然后选择Android.在下面,您必须提供应用程序的确切程序包名称和sha1指纹,然后选择深度链接并最后创建客户端ID.

创建完成后,请为播放器youtube视频创建android api键.然后您的api密钥将起作用.请记住,填写软件包名称时,软件包名称将与eclipe或studio中的应用程序相同.

如果在创建客户端ID后更改了包名称,则密钥将不起作用.请记住,pckg名称在此处受限制,并且不必更改.

上一篇:javascript-Youtube Api playVideo方法在某些移动设备上不起作用


下一篇:php-从YouTube API v3的播放列表中获取所有视频信息