google custom search api for android - 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

Related

Youtube data becomes inaccessible against restricted google API key

Though this question is asked several times, but my concern is why there is an error of mismatch of package name and fingerprint when things are absolutely identical (copy-pasted).
Data(videos and stats) For a non-restricted google API key against youtube-v3-api is being fetched properly but as I restrict the key on google console (passing package name and fingerprint in the header of API request) data becomes unavailable. following is the api response statement
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "The Android package name and signing-certificate fingerprint,
"Package_name" and
"Finger_Print", do not match the app restrictions
configured on your API key. Please use the API Console to update your key restrictions.",
"extendedHelp": "Project_Link_Google_Console"
}
],
"code": 403,
"message": "The Android package name and signing-certificate fingerprint,
"Package_name" and
"Finger_Print", do not match the app restrictions
configured on your API key. Please use the API Console to update your key restrictions."
}
}
It says "package name and fingerprint do not match the app restrictions configured on your API key" though these are copy-pasted from code to console.
Finally, I got rid of this issue by passing the sha1 key in the request header call without colons ":"
e.g replacing the following line
"80:F1:B6:4I:2A:Z6:B7:51:9C:BA:21:FC:0C:C8:2F:C5:4Z:20:ZA:X1"
with
"80F1B64I2AZ6B7519CBA21FC0CC82FC54Z20ZAX1"
Previously I was passing the sha1 key in the header as it was mentioned on google developer console.

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 ..

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

Youtube API permission 403 Forbidden error

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.

Google Map API For Near By Place By Latitude and Longitude

I have an Api key, Api console and Sh1, and using EclipseIDE ANDROID -> preference, I
added all data in Api as below:
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=48.859294,2.347589&radius=5000&types=food|cafe&sensor=false&keyword=vegetarian&key=AIzaSyCRQ2aFtbU2sOgO6fMvuM2edHPaWRDxbRg
But I get this error message:
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key.",
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
What am I doing wrong?
I request you to Use following API
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=48.859294,2.347589&radius=500&types=school&sensor=false&key=AIzaSyDN1QX-gWUR-mIYo_D21PNFLHHpNQkIkGU
So I had the same issue you were experiencing, I used the same api as you however what I found was that if you generate a new API key for android it does not work, but if you generate a new Server key and use that it works perfectly. I found some assistance on the following post REQUEST_DENIED with Google Places API browser key or app key?

Categories

Resources