Google Places API to find the nearby places - maps

I am trying with the Google API
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=12.9566949,77.5606206&radius=500&types=parking&sensor=false&key=API_KEY
But response I got is like this:
{
"error_message": "This API project is not authorized to use this API.",
"html_attributions": [],
"results": [],
"status": "REQUEST_DENIED"
}
I have enabled Google Places API and Maps Embed API in the dashboard. And this is not for Android or IOS. I want to make this API call from the backend.
I have gone through some of the answers like to enable "Google Places API Web Service" in the dashboard. But currently this option is not available.
And some people told to disable the places API and enable it again to make it work. Still it did not help me.

Related

Problem with Firebase API Restriction settings

I have a problem with the Firebase API Restriction settings.
I want to add HTTP restrictions to secure the data but when I add restrictions, it is not working. What am I doing wrong here?
■Website deployed with Github Pages (ex.https://username.github.io/project-name/) It is a React app deployed following this description: https://github.com/gitname/react-gh-pages
■I am using Firebase Authentication. https://firebase.google.com/docs/reference/rest/auth#section-create-email-password
■To secure the API key(although I know Firebase API is no problem, just in case), I wanted to set like below in Google Cloud⇒API & Services⇒Credentials
application restrictions: HTTP referrers
website restrictions: https://username.github.io/project-name/* (used /* since there are many paths in the website)
(When I leave no.2 empty and accept all websites, it works so probably this setting is wrong...)

Cannot ENABLE any API when there is a pending request to DISABLE any API

Yesterday I try to disable "Google Cloud Datastore API (v1beta2)" API for two google cloud projects. Unfortunately it seems there was some kind of error as the popup window with something like "Sorry, there was an error on our side" appeared.
An API disapear from list of API but now when I try to enable either "Google Cloud Datastore API (v1beta2)" or "Google Cloud Datastore API" (which is v1beta3) I receive following error:
"Cannot ENABLE any API when there is a pending request to DISABLE any API"
Please help, thank you
Unfortunately, it looks like Google needs to manually solve this for you. I have the same issue, and it being Sunday, it's hard to get support.
Edit: I was directed here https://code.google.com/p/google-cloud-platform/issues/list
There is currently a bug with disabling v1beta2 that causes the operation to hang for a long time.
By design, you can't enable an API when there are other pending enable/disable operations.
We are actively working on the problem. Sorry for the inconvenience!

Showing Google Analytics Data in real time

I would like to show number of visitors on a site since beginning of the month, number of users on the current day and currently on site.
I have Google Analytics installed, I tried to solve this issue with Embed API by enabling Google Analytics API from developer console - but I requires user authorization, etc.
What would be the easiest way to show analytics on-site without user authentication and accepting access by Embeded API, etc. Application is written in Angular, so Javascript API is the one I look for.
Thank you for any suggestion.
Authorization has to happen in order to get the data you want. Either you can let visitors to your site authorize themselves, or you'll have to authorize server-side on their behalf.
Once authorized, you can do something similar to what the Third Party Visualization Embed API demo shows. It uses a custom ActiveUsers Embed API component and includes the source code to show how it works.
Whether you use the ActiveUsers component or not, the basic gist is that once the users is authenticated via the Embed API, you have access to the method gapi.client.analytics.data.realtime.get, which you can use to query this data.
Here's where that happens in the source code for the ActiveUsers component:
https://github.com/googleanalytics/ga-dev-tools/blob/master/src/javascript/embed-api/components/active-users.js#L69-L87
Authentication with the Analytics service is mandatory. But the OAuth 2.0 Service Accounts (for Server to Server Applications) can be used to automate it in many cases.
It's unclear to me (from a quick scan) if the Auth options of the Embeed API would work with the automated authentication scheme, you may want to go through the details.
You should be able to use the Analytics Core Reporting API and maybe the Analytics Real Time Reporting API (beta) which work with the automated authentication according to their guides (look for the Authorisation sections on the left frames of the respective guides).
Donno if this qualifies as easy, tho, YMMV :)

Disable API discovery for API Explorer

I'm new to App Engine and am trying to figure out how to disable the API Explorer from showing all my APIs, which are currently public and available to anyone visiting [MYPROJECT].appspot.com/_ah/api/explorer
Supposedly Snapchat uses AppEngine, however visiting https://apis-explorer.appspot.com/apis-explorer/?base=https://feelinsonice.appspot.com/_ah/api#p/ does not reveal their APIs.
Viewing network activity for that page you'll see that requests are being made to https://feelinsonice.appspot.com/_ah/api/discovery/v1/apis but returning a 404.
How do I do the same?
When visiting the API Explorer using my project ID I see this:
Is this the culprit?
Endpoints is the 'culprit'. I'm assuming you are using endpoints since you've included that tag, and I guess snapchat doesn't use endpoints.
There is nothing you can do to change this other then stop using endpoints.

Is it possible to access Google Play Game Services API with service account?

I've created the game thru Google Play Developer Console (it is ready for testing, but not published yet).
Two service accounts are added there as testers - myappid#appspot.gserviceaccount.com (Google App Engine service account) and 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc#developer.gserviceaccount.com (manually created service account, it was created before an access to Google Play Game Services API was given). First one is used for production GAE environment, second one is for development environment (run with --appidentity_email_address). Both accounts work well with Google Analytics API.
Now I try to use these accounts to work with Google Play Game Services API.
The following code is used for authorization and works fine:
credentials = AppAssertionCredentials(scope=['https://www.googleapis.com/auth/games', 'https://www.googleapis.com/auth/plus.login'])
http = credentials.authorize(httplib2.Http(memcache))
But I am getting an error when trying to access achievements definition (also tried to get application metadata - got the same issue):
response = service.achievementDefinitions().list().execute()
In development environment I get
<HttpError 404 when requesting https://www.googleapis.com/games/v1/achievements?alt=json returned "The requested application with ID 64436212345 was not found.">
and in production:
<HttpError 500 when requesting https://www.googleapis.com/games/v1/achievements?alt=json returned "">
What is wrong there? Are service accounts supported by Google Play Services API?
Upd. Further analysis showed that 64436212345 is an ID of my GAE application, when an ID of my Google Play application is 760943112345.
So, I went to Google Developer Console for application 760943112345 and added 64436212345-enq9gkd1abcdefghjec2kha39je5ojsc#developer.gserviceaccount.com and myappid#appspot.gserviceaccount.com as the member their. It didn't help.
Then I generated new service account ID there and run GAE locally with this service account. In result, I've started to get
<HttpError 401 when requesting https://www.googleapis.com/games/v1/applications/760943112345?alt=json returned "User has not completed registration.">
Of course, my service account doesn't have Google+ profile.
I am also struggling with service accounts and Google game services, and am stuck at the same point (my service account doesn't have a G+ account).
The only indication I have found in the Google literature (supposedly Updated Jan 22, 2014) says service accounts are not supported:
Warning: Very few Google APIs currently support Service Accounts. Service accounts are >currently supported by the following Google developer services:
Google Cloud Storage
Google Prediction API
Google URL Shortener
Google OAuth 2.0 Authorization Server
Google BigQuery
This is embedded in some google api php client documentation however, so I cannot attest its validity.
Let me know if you have any luck getting this to work and I'll do the same!
Edit: here is the actual answer:
You have to create another API project and link it to your game's project, as explained in Getting Started with the Google Play Games Services Publishing API. The service accounts that you add to your game's project won't work. Also, you have to add this new API project through Google Play Developer Console, and not through Google Developers Console. As far as I remember, you go to the latter to get your key only. This whole situation took me forever to figure out.
I'm keeping the below text for future reference:
Edit: I wrote the answer below, thinking that you did not talk about the Publishing API. But you are, it seems. Or an earlier version of it. I hope the below answer will be useful for people looking to access Management API with a service account:
I struggled with the same and concluded that service accounts do not work with the GPGS Management API, which is the API that deals with achievements and things of that sort. Here are the facts that I used to reach this conclusion:
The only place in GPGS docs that service accounts are mentioned is the Publishing API.
Management API Docs contains descriptions for each function about the authorization requirements such as: "This method is only available to user accounts for your developer console.", while Publishing API Docs have no such descriptions.
The sample app for Management API does not use a service account.
It would be nice if this was a bit clearer in the GPGS docs. The generic Google Cloud docs that they link from GPGS pages made me believe that service accounts would work.

Resources