Add tinymce API Key in google app scripts - javascript

I had been trying to add TinyMCE in a Google App Scripts project. In order to do that I got an API key from TinyMCE and added domain http://script.google.com to the domain list for the key.
Then added the API key to using the code below -
<script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=API"></script>
But when I tried to call the TinyMCE in that project HTML file, I got an error saying that -
The domain is not supported by your API key. Please review your domain settings here.
Snapshot of the error on the page for TinyMCE when page is loaded

a quick console.log(window.location) reveals that the hostname is something else. In my case it is n-4fcnzkskmuesjcsczo67y2qkpk3vxmg4aionr6i-0lu-script.googleusercontent.com
It could be a different hostname for you since I think any number of google servers could be serving your page.
So try adding googleusercontent.com to your API settings in TinyMCE.

I think this issue is with tinymce and not Apps Script. Try the answer provided in this tinymce forum which encountered the same error.
If you tried to use your API key before you added these other domains
the key is likely cached on our servers. The TTL is 4 hours so it may
just take some time for the other domains to be valid.
We will be enhancing the domain registration/addition process to flush
the cache when you make changes in an upcoming release of our cloud
environment.

Related

Vanilla JavaScript version of Google's UrlFetchApp

I'm working on an html file in a google apps script project right now and I want it to be able to retrieve the html content of a web page, extract a snippet, and paste the snippet to the page. I've tried using fetch() and a couple of its options (mostly CORS), but I either get nothing back or an error that says "No 'Access-Control-Allow-Origin' header is present on the requested resource." A workaround I found was using google.script.run.withSuccessHandler() to return the html content via UrlFetchApp.fetch(url).getContentText(). The problem with this is that it is time consuming and I want to try and optimize it as much as possible. Does anyone have any suggestions on how to make this work or will I be forced to stick with my workaround?
Using "Vanilla JavaScript" in a Google Apps Script web application might not work to
retrieve the html content of a web page, extract a snippet, and paste the snippet to the page.
The above because the client-side code of Google Apps Script web applications is embedded in an iframe tag that can't be modified from server-side code. In other words, Google Apps Script is not universally suitable web development platform. One alternative is to use another platform to create your web application, i.e. GitHub Pages, Firebase, etc.
Related
Where is my iframe in the published web application/sidebar?

Google Spreadsheet Script Trigger: This app is blocked

I am trying to create a trigger for a script in google spreadsheet and upon trying to save the trigger I am getting the following error:
This app is blocked This app tried to access sensitive info in your
Google Account. To keep your account safe, Google blocked this access.
I don't have G-Suite, I don't have an organization, I am simply using my personal Gmail account. I don't have the special account protection thing enabled. I tried using different scripts, even an empty script.
What could be the problem here? I have used scripts and add-ons in the past, but haven't needed triggers yet. Is there another way to run a script daily or monthly, without this trigger functionality?
There is currently a bug
I recommend oyu to "star" it to increase visibility, so it hopefully gets fixed soon.
Try this:
Unable to open Google xlsx spreadsheet / Also Google Drive permission Blocked
The same solution logic can solve this problem.
[ ]

Using Google Map JavaScript library with cordova

I am trying to use Google map JavaScript API with a cordova project,
I am getting the map, after few seconds, I am getting RefererNotAllowedMapError for file:///android_asset/www/index.html
I tried to provide this URL on the developer console also, but no luck.
I tried to provide wild card asterisk symbol
Is there any other way to set a custom referrer or how to solve this?
---EDIT---
I was using Browser API key, I changed to Android API key now it works fine.
Wrong Value for cordova: https://maps.googleapis.com/maps/api/js?key=<browser api key>
Proper Value for cordova: https://maps.googleapis.com/maps/api/js?key=<android api key>
Browser API key seems to be only allowed when the html page is executed on a http url
As of May 2017, the issue has been solved by Google. Now you can use file:/ referrers with API keys. You can see the following text in the documentation
file:// referers need a special representation to be added to the Key restriction. The "file:/" part should be replaced with "__file_url__" before being added to the Key restriction. For example, "file://path/to/" should be formatted as "__file_url__/path/to/*". After enabling file:// referers, it is recommended you regularly check your usage, to make sure it matches your expectations
https://developers.google.com/maps/documentation/javascript/get-api-key#key-restrictions

Google api key not working [duplicate]

I am developing in JavaScript/HTML/CSS an app that uses Google Maps. I am getting the following alert dialog box:
"This page was unable to display a Google Maps element. The provided Google API key is invalid or this site is not authorized to use it. Error Code: InvalidKeyOrUnauthorizedURLMapError"
The app does actually display the map element; the alert is not a problem except it should not appear at all. The map displays properly.
I have gone in to the Google Developer's Console and, in the "Credentials" section, have "edited allowed referrers" to be mydomain.com/*
I have also gone in to the Google Developer's Console in the APIs section and enabled 11 Google Maps APIs.
After lots of referrer combinations, deleting and re-creating credentials i realized that i didn't enabled "Google Maps JavaScript API". What a shame. :)
For anyone who is having trouble to get google maps api work please check if the API enabled first.
After struggling a lot with this issue I've found 1 solution for me. It might help people who are searching for a proper and exact solution but not the comments, downvotes and links.
(Map was not displayed in my case.)
If suppose,the link of page where you are loading map is
http://example.com/abc/def/ghi/kpn.php
then give thesame(exactly the same) under Edit allowed references
If you try loading the same page using:
www.example.com/abc/def/ghi/kpn.php
or
http://www.example.com/abc/def/ghi/kpn.php
then your page is loaded but not your map, and this alert is generated.
CONCLUSION
Use the same path(Url address) at these 2 places.
While loading the page which has map.
Under Edit allowed references.
After following this I've got rid from this alert.
First you need to go to https://console.developers.google.com/ and select APIs.
In Google Maps APIs select Google Maps JavaScript API and make sure you enable API for Google Maps JavaScript.
Secondly, you need to create an API key:
Go to Credentials
Create new key and select Browser Key
No need to specify any referrers
So you should see Any referrer allowed after you save.
After a lot of trial and error this worked for me (by Eduardo. Thanks !)
The URL that needs to be authorized is the one in the Referrer header for the requests the browser sends to Google to load the API.
Under Browser Credentials > REFERERS
Add these
.example.org/
www.example.org/*
http://www.example.org
http://example.org
geocodezip provided the info i needed. I was indeed loading the googlemaps library twice: once in my index.html file and once in an iFrame. I changed my code so that the iFrame did not load the googlemaps library but, instead, used the parent. Thanks geocodezip!
Go to APIs menu and find "Google Maps JavaScript API" after you open it just press "Enable API"
I was able to get this to work by deleting all my referrers and allowing all. Apparently there is a bug in the developer console that is causing problems. Some people say that they can get referrers to work by deleting all then adding all back in at once instead of line by line:
https://productforums.google.com/forum/#!topic/maps/mSVyDazRMQo
Previous things I tried:
Regenerating Key
Setting all maps apis to enabled
Hard coding absolute paths of referrers
A side note, when I didn't include my api_key everything worked fined, though I'm sure they will eventually turn you off if you don't use your api_key.
What worked for me was to use Firebug in order to find the exact URL that made the request to the Google Maps API. As stated in Google Maps API documentation on troubleshooting authorization, "How to find the correct URL" part:
The URL that needs to be authorized is the one in the Referrer header
for the requests the browser sends to Google to load the API.
In my case, lets suppose I have a website example.com. In the developer console, under Google Maps API key, I've added many combinations of referrer such as example.com/*, *.example.com/*, example.com, but still the InvalidKeyOrUnauthorizedURLMapError persisted.
My solution, as I've mentioned, to use Firebug: open example.com and look for what was the referrer making request to https://maps.googleapis.com/maps/api/js?..., and it was http://example.com, and that is it. I've added http://example.com/* to the enabled URLs in the Developers Console under my respective API key and now everything works fine.
It is important to know where to look for on Firebug: it is the Net tab. Just click on the request to maps.googleapis ... and look for the Referer
I got it to work by exchanging the keys with my own special created keys AND reading this webpage a few times very carefully. My advice is to add or exchange your Google API Keys at https://console.developers.google.com/apis/credentials before embarking in very complicated scripting.
Insert your own API keys in the very first line of the Google Map javascript:
If you have been setup all configuration like api key etc, and you still got the error,
please enable all your mandatory APIs regarding to google maps.
Like:-
Google Maps Embed API
Google Maps Geocoding API
Google Maps Geolocation API
Google Maps JavaScript API

Why can't I get the full URL from a Google search

I search Google for a phrase which brings up my website.
Google shows a URL similar to
https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=my%20search
This brings up my website. On the landing page of my website, I have the following javascript
alert(document.referral);
This shows me the value
https://www.google.co.uk/
No querystring!
Research suggests the issue is likely due to my website being HTTP but both Google and my website use HTTPS
Why can I not get the search phrase from the query string?
Edit
Based upon the links I've been provided (thanks) I can see what you are claiming the issue is. Google doesn't allow it! However, I'm not sure I agree with this - there are many web analytical programs which provide this information. The company I have used (which admittedly can only provide keywords for 5% of all visitors) can do this... And I only embed some javascript. I can only assume it's because visitors can home HTTP:://google as opposed to HTTPS::google
have a look at this document: http://blogs.adobe.com/digitalmarketing/analytics/the-impact-of-google-encrypted-search/
It apparently has something to do with google running HTTPS. on my local tomcat server running HTTP, i get
http://servername/tools/errorlog.jsp?env=Prod&logType=EXTAUTHLOG when running
alert(document.referrer) in a console
Duplicate of:
How can I get the correct referer via JavaScript if the referrer uses https? ??

Categories

Resources