Getting : ipRefererBlocked on android app - android

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

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

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.

Why is my api key not accepted by the Google Directions (Android) request?

Whenever I include my Google Play Services API key along with my request for Google Directions like in the code below:
private String makeDirectionsURL(double originLat, double originLong, double destLat, double destLong)
{
StringBuilder url = new StringBuilder();
//first part of url//
url.append("https://maps.googleapis.com/maps/api/directions/json?");
//start adding parameters//
//origin coordinates
url.append("origin="+originLat+","+originLong);
//destiniation coordinates
url.append("&destination=");
url.append(destLat+","+destLong);
//api key
url.append("&key=");
url.append(getResources().getString(R.string.google_api_key));
//NOTE: for some reason, the request suceeds when leaving out the api key
return url.toString();
}
When I include the api key as a parameter in the request, the json response shows that my request has been denied. The response reads:
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key.",
"routes" : [],
"status" : "REQUEST_DENIED"
}
Yet the same api key works for my google map view - and my api console registers the accesses for the map view quota limit. Even odder yet, when I leave out the key parameter in the Directions request I get a valid JSON response.
I have a feeling that I have to generate another different api key for just the Google Directions service - but I'm not sure how to. The documentation here:
https://developers.google.com/maps/documentation/directions/#api_key
Says to visit the console and activate the Directions API service - I did.
Then it says my api key "will be available from the API Access page, in the Simple API Access section. Directions API applications use the Key for server apps." Now is where I'm confused - how can I use the key for server apps if I am accessing from a mobile device - I'm assuming this is for any webpages that wish to use the service - but what do I do for an android app. As I said, I already tried using my Simple API Access key for Android apps, which I know works, yet when I pass the same key to Google Directions - it mysteriously doesn't work...
Any help, vague guidance, or links to read up on would be really appreciated.
PS: If I can't figure this out - am I allowed to keep sending requests w/o a api key?
I think the issue is because you are trying to pass a server key which is directly tied to your server's IP address, when you should be passing an android app key.
In your Google APIs console, navigate to API's and Auth. From here you can create a new public API key.
When prompted, select Android Application
You will need to enter your device's SHA1 Certificate Fingerprint
This comes from the keystore used to sign the apk. When running an app in debug, you will most likely be using your IDE's debugging keystore. Google has a nice write up on how to get this information.
When releasing the app, you will need to sign it with your own key. You will either need to edit your API key to the new keystore SHA1 fingerprint or create a new API key.
Additionally, according to Google, you should be using a key.
All Directions API applications should use an API key. Including a key
in your request:
Allows you to monitor your application's API usage in the APIs
Console. Enables per-key instead of per-IP-address quota limits.
Ensures that Google can contact you about your application if necessary.
While I can't comment on how strictly they enforce this, I strongly encourage you to do so to avoid any issues down the road.

Place API for Android

I'm trying to use the Google Places API in my application. For that I need to generate Server Key.
I used my device IP address to generate a Server Key. My app works only in my device. If I use some other device I get an error:
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key.",
"predictions" : [],
"status" : "REQUEST_DENIED"
}
Could you please help me in this regards. How to generate Server key which works for all devices.
Try to create a new Places API key. When creating the key choose the server but leave the IP field blank (so as to allow any IP address).
Notify and vote up if it works.

Categories

Resources