Youtube API permission 403 Forbidden error - android

I'm following the tutorial on this page but I keep getting a 403 Forbidden error when I run the app and try to do a search.
I enabled Youtube Data API v3 on the https://console.developers.google.com/ page and I created an Android API key.
Any suggestions? Thank you.
Could not search: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"reason" : "ipRefererBlocked",
"extendedHelp" : "https://console.developers.google.com"
} ],
"message" : "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}

I have resolved the problem by creating a Browser key instead of an android key. The browser key needs to have no entry so that it'll say "all refered allowed"

Used this for iOS app and received same error so I removed bundle identifier and it worked

I have resolved the problem by creating a Server key instead of an iOS key

I had the same problem and after a lot of wasted time my hosting service figured out the API request was being generated by a different IP address than the one associated with my website.

For anyone who finds this that couldn't solve it with the answers above, my problem was the way I entered the domain into the API restriction. I had put *.example.com/*, but my requests were coming from https://example.com. When I removed the *. at the beginning, my requests began working.

Related

Access Not Configured. YouTube Data API has not been used in project 608941808256

I have enabled YouTube data API and Google+ API for my project and change the Android API Key in Auth.java I also entered my playlist info into Constants.java. However I still get this unhelpful error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Access Not Configured. YouTube Data API has not been used in project 608941808256 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=608941808256 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"reason": "accessNotConfigured",
"extendedHelp": "https://console.developers.google.com/apis/api/youtube/overview?project=608941808256"
}
],
"message": "Access Not Configured. YouTube Data API has not been used in project 608941808256 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube/overview?project=608941808256 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
}
can some one help me please
We had the same issue. We resolved it by starting from scratch and creating a brand new API project. For some reason the existing API project didn't work. Steps to check if you have this issue:
Create a new project in the API console (click the project dropdown at the top of the window, and choose "New project").
Enable the APIs required (e.g. YouTube Data).
Go to credentials->Domain verification and enter your domain.
Fill in the OAuth consent screen, and make the "application name" the same as your project name. Also choose the scopes you will be using, add your domain, save it, and submit for verification.
Create credentials of type "OAuth2 client key->Web application" and enter the correct callback uri.
Wait a few hours.
You should now be able to test in the APIs explorer (enter your own client key).
I had the same problem here.
Besides enabling the Google+ API and the Contacts API I have also to create a new OAuth Client Key for Web applications.
When you create it you'll see that the client id will start with the Project Id that you have on the error message.
In summary you'll have to do as follow:
Create an OAuth Client Key with type web application
And the Client Id to you API
Then you should be able to authenticate.
Hope I could help.
I Solved this problem by creating a new project and then creating new credentials

Getting video title using video id in youtube api v3 (Android)

I am trying to get youtube video details using the video id in youtube api v3. Using this url :
https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=AIzaSyCA-EL5sT5LCQnYauNMm2Ku_PukvBcz6ms%20&part=snippet,contentDetails
I get the return of :
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "The Android package name and signing-certificate fingerprint, null and null, do not match the app restrictions configured on your API key. Please use the API Console to update your key restrictions.",
"extendedHelp": "https://console.developers.google.com/apis/credentials?project=861763996907"
}
],
"code": 403,
"message": "The Android package name and signing-certificate fingerprint, null and null, do not match the app restrictions configured on your API key. Please use the API Console to update your key restrictions."
}
}
The api key is the key is the one I got after registering the app using my SHA1 code in google developer console. How to get over this error?
you can make a service with GET method from mobile.All you need to do is to create a server key and append this key and video id with the url and get data
for example: if you are using Volley for HTTP requests then in JsonOBjectRequest url parameter should look this:
"https://www.googleapis.com/youtube/v3/videos?id=F4HuIqwGuBU&key=YOUR_SERVER_KEY&fields=items(id,snippet(description,channelId,title,categoryId),statistics)&part=snippet,statistics"
hope this helps.
enter image description here
This is Happening just because you havent Cleared the Security restrictions from Console Key..
Try these Steps
Step 1 :-
Go to Your Project & Click on Credentials..
(https://console.developers.google.com/apis/credentials/key/216?project=)
Step 2:-Generate API key and click on API key
Step 3:- Click on no Restriction and Enjoy ..

google custom search api for android

When I am trying to run the below URL:
https://www.googleapis.com/customsearch/v1?q=a&key=AIzaSyAlA7Vv79S_pH8tWjD-SAFUIlVh2ZzHw2o&cx=002019692856142923148:nijox13azs4
the response is:
{"error": {"errors": [{"domain": "usageLimits","reason":
"ipRefererBlocked",
"message": "The referrer null does not match does not match the referrer restrictions configured on your API key. Please use the API
Console to update your key restrictions.","extendedHelp":
"https://console.developers.google.com/apis/credentials?project=672025619957"}],
"code": 403,"message": "The referrer null does not match does not
match the referrer restrictions configured on your API key. Please use
the API Console to update your key restrictions."}}
I have generated the browser api key.. please tell me where is my mistake?
Thanks in advance

Getting : ipRefererBlocked on android app

I'm trying to use the "Google Identity Toolkit" with the "tutorial" android demo app, but now I get this error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
}
Any Idea? In the Google console I need allow some thing? Where?
OAuth 2.0 client IDs:
Android,
Web application
And on Identity Toolkit API console, it allow I select "Web application" client ID in Google provider.
And I have set up this in my "tutorial" app
This error is usually caused when you are trying to run the code on a URL you didn't add to the referrer URLs in the console.
To fix this go to the Google Developer Console, then under API Manager click credentials and find your browser key. On this page you can add any URLs that will be using that key.
Remember it treats www. differently, so to cover all possible pages you could do this:
.domain.com/
domain.com/*
I figured out today that there is a bug when you create a new Android API key. You will have probably noticed that there was also a Browser API key that was generated when you created the Android API key. My Browser API key had no name, and was therefore not configurable. However, I performed a bit of URL manipulation magic to be able to access and edit my Browser API key. Here's what I did:
1) Click on the name of the Android API key
2) Edit the URL right before the ? such that the number before the ? matches the (0-based) index of the position of your Browser API key. That is, if your browser api key appears second in your list of two API keys, then your Android API key would have been first, at position 0. Therefore the URL would read something like this:
.../key/0?...
So now you want to change it to look like this:
.../key/1?...
3) From here you should be able to change your allowed referrers to
http://yourdomain.com/*
Then, so long as you have your keys set up properly everything should work as expected! Also, note that after you do this once you will then have a name for your browser key, and it will be easily editable in the future!
Best of luck!
You will need to...
Create an Android API Key
Set the package name and SHA-1 of your signing key file(see gitkit guide on how to do that)
Use that API Key for the identitytoolkit.api_key value

unable to get the routes from the google api

I got the api key by following the usual steps.
Then I was able to get map and use some inbuilt things on it like search etc
Then later I tried routing, I was unable to get the routes. When I pasted the request:
https://maps.googleapis.com/maps/api/directions/json?origin=28.6100,2077.2300&destination=18.9750,72.8258&key=mykey
on the browser I got the following and realized that I don't have the permission. I searched for this problem but couldn't find the solution, please help.
Response on browser:
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address xxxxxxxx, with empty referer",
"routes" : [],
"status" : "REQUEST_DENIED"
}
Make sure you are using server API key, not an Android key (mobile development). See this post:
Google Places API request denied for Android autocomplete, even with the right api key .
Also make sure you are sending the key to GooglePlaces instance.
If you are restricting use of API key by IP make sure your request is coming from an allowed address.

Categories

Resources