Google Apps Script - origin_mismatch error in Google Site - google-apps-script

I'm aware there is a very similir here. But this assumes that you are developing a web app on a html fle uploaded to your own server domain. How do I need to set up the Javascript origins in the API project console when I'm working on a Google Site?
My Google Sites URL looks like https://sites.google.com/a/domain-name.com/site-name/page-name. I can't paste that URL since it says that the origin domain can't containt a path like http://example.com/subdir
Here is the error that I'm getting:
That’s an error.
Error: origin_mismatch
Application: Custom form
You can email the developer of this application at:
my-email#my-domain.com
Request Details immediate=false response_type=token
scope=https://www.googleapis.com/auth/drive.readonly
redirect_uri=postmessage proxy=oauth2relay945850002
state=845063282|0.3789568949
origin=https://n-qaqvqexe4f52wy3jge4j7oquqn5qtfw3gn4sumq-script.googleusercontent.com
include_granted_scopes=true
client_id=498878908299-opvf61qsrpr6en5kvh74esqbmii1nc7u.apps.googleusercontent.com
authuser=0
And this is the example code that I'm using

After wasting lot of hours, adding the URL after ss_domain= to the Authorized JavaScript origins worked for me.
From the error windows click on Request Details, look for ss_domain and copy that uri in the JavaScript Origins.

Related

GAS embedded in Google Site requests "insecure resource" whereas it worked before

I am using Google Apps Script's Visualization API to generate charts/tables and have about a dozen such scripts successfully embedded in Google Sites. Yesterday, I created a new script and tried to embed it into a Site by [Edit Page | Insert | Google: Apps Script] as usual. I received the following error seen in the Console:
Mixed Content: The page at
'https://sites.google.com/a/globalfoundries.com/aleister_projects/'
was loaded over HTTPS, but requested an insecure resource
'http://sites.google.com/a/globalfoundries.com/sites/system/errors/WebspaceNotFound?path=%2Fmacros%2Fs%2FAKfycbwuIGzoNErAzb2mqL5HRrVc6xeQTaavvycUXLhi1rSVSeF1ZUSM%2Fexec'.
This request has been blocked; the content must be served over HTTPS.
After some unsuccessful trouble-shooting with my new script, I attempted to embed a second copy of an existing script that I know has successfully generated a table into an existing Site directly below the existing copy of this script (see attached image). The result is that the original copy of the script that was embedded a few months ago renders fine, but the re-embedded copy inserted directly below it generates this error.
Is anyone having this issue? Has anyone seen this issue? Can anyone provide some insight? I'm not sure if there is some security change at my organization or if there is some Google-side update about which I am unaware. Thank you !
I had the same problem, and this is what I did to solve it:
I noticed that the format /exec link generated has changed.
Old format (supported in classic google site)
https://script.google.com/a/macros/your-domain.com/s/xxxxxxxxxxx_S61g09Dk/exec (macro was before the domain)
New Format (not supported in classic google site)
https://script.google.com/a/your-domain.com/macros/s/xxxxxxxxxxx_S61g09Dk/exec (macro is now after the domain)
Modifying the url after generation is the only solution I found. Hope this will help you.

How to change ClientLogin to OAuth 2.0 in Google Cloud Print?

Currently I trying to test the Google Cloud Print sample code in this link.
Sample Maven project
And I unsuccessful to RUN it.
I encounter FileNotFound error.
Then I start to browse the request url
ClientLogin url
This url redirect me to another documentation url ie:
AuthForInstall Url
and I found out that GoogleCloudPrint was totally deprecated and no longer available.
Now google using OAuth 2.0.
May I know how can I change ClientLogin to OAuth 2.0 in Google Cloud Print?
Thank you.

Google Drive SDK: using drive.install scope to integrate web app into "open with" UI not working

I have tried without much success to integrate my web application within the Google Drive UI (to open files). I cannot get the app to install using the OAuth scope https://www.googleapis.com/auth/drive.install.
I was wondering if anybody could share their Drive SDK configuration to see if I missed something. I tried installing my app using the Google API Console by selecting the Drive Integration to automatically authenticate. I also tried manually making the OAuth request using the google-api-client gem.
I always get the permissions dialog and I can see the following being requested: Add itself to Google Drive. I also get redirected back to my application like a normal OAuth request, but the application is never listed in Google Drive.
I have been requesting the following scopes:
https://www.googleapis.com/auth/drive.install
https://www.googleapis.com/auth/drive.file
profile
user
Allowing Import and these Secondary MIME Types:
application/vnd.google.drive.ext-type.html
text/html
I followed the documentation here: https://developers.google.com/drive/web/enable-sdk
Thanks in advance for any help!!
I was able to solve this by modifying my OAuth flow. It wasn't exchanging the authentication code for an access token before. Once I made it to that point everything worked as expected.
My issue was, that I didn't have this set:
Allowing Import and these Secondary MIME Types:
application/vnd.google.drive.ext-type.html text/html
I'm working with Google Spreadsheets, so I need a mime type that a sheet can be converted to, such as text/csv, see https://developers.google.com/drive/api/v3/integrate-open#open_and_convert_google_docs_in_your_app

Google Docs viewerng api reference

I am trying to show a file hosted in a public site inline on my web page using google docs by providing the following URL to an iframe.
https://drive.google.com/viewerng/viewer?url='+link+'&embedded=true
where link is the path to the file I want to show.
I am facing some issues with showing files which require user authentication.
Hence would like to see reference documentation for the API. I searched for it online was unable to find any reference documentation for the following service end point.
"https://drive.google.com/viewerng/viewer"
Let requests originating from this Google service pass your authentication
Include a secret parameter in the link to confirm that an authenticated user (of your site) is requesting the document (via viewerng)

Google-Apps-Script/Google-Drive cors issue

I have created a Google Apps Script in Google Drive. Although the script was created in Drive, it has a URL that looks like:
https://script.google.com/macros/s/blah-blah-blah
As a result, attempts to stuff the output from the script into a web page hosted on Google Drive fail as an attempt to access a cross-origin resource. Any way I can get around this problem? Thanks for any input.
... doug
you could publish the gas as anonymous content script and use ajax to get the data (redirects enabled) and use regular client+side js to display it on your googledrive html page.
Maybe its not working because you havent published as anonymous?
Ive done ajax to a gas content script from a googledrive.com hosted page and it worked fine.