Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

android - YouTube API : com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden

I am new to YouTube APIs. I have downloaded and imported yt-direct-lite youtube android project from github in my eclipse. Everything is fine. But, when I run the project it toast/pops up error message that :

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

However, I have already turned on Google+ API as well as YouTube Data API v3.

Also, I have generated API key. All the things are fine but when it goes to sign in for Google/Gmail account in the project. Also, fires below exception.

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

I don't know what's wrong with it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have solved this problem after some RnD. The thing is first enable youtubeapi v3 and google+ api then go to credential and before generating Android API key.

First generate the client id by clicking "create new client id" then select installed application and choose Android. Below you have to give the exact package name of you app and sha1 fingerprint then select deep linking and at last create client id.

After created then create the android api key for player youtube video. Then your api key will be working. Remember in filling your package name, your package name will be same with your app in eclipe or studio.

If after creating client id, you changed your package name then you key will not work. Remember pckg name is restricted here, and will not have to be changed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...