Google Api - Key with file:// protocol - file

I have a little problem with the google api loading script.
I try to load the map api with this script tag :
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&libraries=places&language=en-US?key=xxx"></script>
The problem that I have is that google keep telling me :
Google has disabled use of the Maps API for this application. This
site is not authorized to use the Google Maps client ID provided. If
you are the owner of this application, you can learn more about
registering URLs here:
https://developers.google.com/maps/documentation/business/clientside/auth#registering_authorized_urls
I have tries to set the allowed referers to "*", and to not specify any referer at all, but always get the same error message.
I think that it's because I'm in a phonegap (cordova) app and that the page where the script tag stand is loaded by file:// protocol...
Some of you have already solved this issue ?
Thanks in advance!
Cheers!

You don't need to use the map api key with file:// protocol. Google checks the web site domain, but file:// protocol does not have it, so you can skip it.
By the way, phonegap-googlemaps-plugin brings native Google Maps view into your Cordova app.
It's better performance (although less functions than Google Maps JS API v3).
Just for your information.

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

How to access the Google Maps Directions API client-side from a library

I'd like to send requests against the Google Directions API. Google provides a Node.JS client library for the API. However, this AP is server-side only. Attempting to use it from a browser script results in a CORS failure. Multiple past answers (such as this one) indicate that this library simply can't be used in this way.
The alternative is to use the client-side JavaScript API. However, this requires adding a <script> tag to the document root. That's the wrong level of abstraction for my needs. I'd like to use a method from a library or dot-js file instead.
Following the advice given here, I'd like to ask: is there a module available through npm I can use to query the Google Directions API client-side?
It's not naively possible to access the Google Maps Directions API from the client side. Web browsers implement the Single-Origin Policy, which requires that any requests to a domain come from the same domain. Requires between domains are disallowed by default. Cross-domain requests can be enabled at the server lever by setting the right CORS headers on the endpoint, but the Google Maps servers choose not to do this.
There are two ways of working around this. One is to wrap the request using the Google API Auth library. However, I could not get this to work.
What did work was using a reverse proxy. This workaround is actually mentioned in the Google Directions API intro page (albeit obliquely). You will need to set up a server which forwards any requests to an API request, then returns that API request to the original requester. Since this is now a server-side request, SOP will not apply, and you will be good to go.
For an example implementation check out this repository on GitHub.
https://developers.google.com/maps/documentation/directions
This is the Directions API web service. It does not require adding a <script> tag.
You can make direct requests to the service as per the example:
https://maps.googleapis.com/maps/api/directions/json?origin=75+9th+Ave+New+York,+NY&destination=MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073&key=YOUR_API_KEY
once you have generated an API key and replaced YOUR_API_KEY in the request with your own key.

Rejected request to participate in Google AdSense (Phase 1)

I am trying to register my web app for the service of Google AdSense.
After five attempts are still stuck in the first phase for the error: Content insufficient.
My web app is a search engine for youtube, developed with AngularJs and NodeJs
AngularJS fully embraces the asynchronous model and this is what creates problems for Google's crawlers. So I implemented the library prerender.io and I have set up the meta tag to fix any problems with the # of Angular.
 
<meta name = "fragment" content = "">
I also prepared the sitemap.xml within the site, and that index the pages through the portal of google for webmasters.
The site being a search engine, does not have static content and reach, so I also added some texts and descriptions in the page principle, which houses the other partial files.
Despite these changes, I could not pass the first stage, how can I do to fix?
I'm not making all the necessary steps for a web app Angular?
To be approved in Google Adsense you need about 10 topics of 400 words. The content should be unique. According to Google Adsense TOS it is not allowed to put ads in pages having copied content. So in your case if you provide search results you will provide copied content.

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.

Accessing Google Calendar API from AngularJS APP

I am implementing (I am trying to implement) a 100% client side AngularJS web app which should access the google calendar API. Of course, this doesn't work because I hit the cross domain problem:
XMLHttpRequest cannot load http://... . Origin http://localhost:9000 is not allowed by Access-Control-Allow-Origin.
Is there any solution to bypass this issue, except creating a proxy? By setting some header or changing some google configuration? I don't see one ...
Great hint Philipp! The google javascript api client (see here) does the job.
But I am wondering: How does the google javascript api client bypasses the cross domain issue? Does someone know?
You need googles side to return the right headers, Access-Control-Allow-Origin, to your browser so it doesnt complain about the cross browser issue.
Make sure in the google cloud console is configured correctly to web application. Im assuming web app because the redirect though.
If its a phoneapp or not serving anything on localhost:9000 redirect endpoint there are other options. For example you could open up the oauth redirect in another window, still use localhost:9000 as the redirect. Even though you are not listening at that port you could still grab the url code or error that is set on the redirect from the parent window.
CORS is an issue that you will experience when running the app through web browsers. I suggest you download a CORS toggle extension on google chrome so you can toggle off CORS and the API will connect. Good luck!

Resources