Accessing Google Sheets API from Google Sites using 'embed': "Not a valid origin for the client" Error - embed

I am trying to access a Google sheet using Google Sheets API. When I tried it locally, I was able to do it. When I tried the same from Google Sites by embedding the code, it gives me the following error.
{
"error": "idpiframe_initialization_failed",
"details": "Not a valid origin for the client: https://<dynamic-number>-atari-embeds.googleusercontent.com has not been whitelisted for client ID <client_id>. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID."
}
As you can see from the error message, which I have edited to hide information, the origin of the embed is dynamic. So I can't update the whitelist on developer console.
Is there a way to solve this somehow?
Thanks in advance

Do you have started your server?
If you are using python3 try this command on same directory where you have placed your index.html file.
python3 -m http.server 8000
For python2
python -m SimpleHTTPServer 8000
Then directly type
http://localhost:8000/index.html
No need to use LiveServer extention if you are using vscode.

Related

Not able to push files using clasp push command

I am able to get the files using clasp pull command but not able to update the files using clasp push command. It says "No files to push".
When I run command clasp status then it shows all of my project files in "Ignore files". Previously it was working completely and the problem occurred yesterday when I changed my laptop.
I also tried making .claspignore file and it also did not work.
For reference, please see the screenshot.
Please help.
I think for me I found the issue after using trying
clasp version "YOUR_VERSION_STRING".
I got a console message to enable API access. Once I enabled that I was able to make pushes. It's funny because I was able to clone and pull just fine.
So this is the Settings URL and then make sure that "Google Apps Script API Access" is on.

Clasp Could not read API credentials. Are you logged in globally?

I'm logging in with clasp login --creds <file> which produces a local .clasprc.json file.
It says that I am logged in, but when I run another command I get:
Could not read API credentials. Are you logged in globally?
Any thoughts on why its not looking at my local clasprc file first?
Currently using version clasp v. 2.2.0
I ran into the same problem on Windows 10 and found that you need to login both globally and locally to use clasp run. There should be a .clasprc.json file in both your project folder and user folder.
I think I have finally found the solution for the same problem
Follow along with the comments from this github issue
Add the "oauthScopes" field to your local code and push it to your app
If you can't push, then copy-paste it to manifest file in the browser
Then you have to publish the app, and there were few things I've done, not sure which one helped. In the app in browser:
add the app version in File->Manage Versions
Publish -> Deploy as API executable
try to login with clasp and creds.json file
try to run something clasp run testRun
it may show the error that you're missing some oauth permissions, but it will list which ones, and you can add them
In my case, one weird thing that also helped was to enable some Google API
so in the app in browser: Resources -> Advanced Google Services -> enable some API
then try to do clasp run
if it works, you can disable the API that you have enabled previously.
Hope that helps

Reauthenticate or Remove authentication Pydrive during runtime in Google Colab

I want to reauthenticate my Google Drive Credentials so that I can login from a different Google account and access it using pydrive. How can I do that?
I am using the following code to authenticate:
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(auth = gauth)
I want to get a fresh token and option to login again into a different google account?
Thanks for helping!
Try deleting the credential file produced by auth.authenticate_user() based on the auth module
rm /content/adc.json
I have just found a solution to this issue. If one goes to his/hers Google Account Settings->Security->Signing in to other sites(all the way down)->YOUR PROCESS NAME and then simply remove it. If you try simply listing the files in the authenticated drive again it should fail with "Token has been expired or revoked."
Just make sure when you create and enter your correct account credentials to delete the credentials/client_secret.json file as the settings.yaml does not seem to overwrite
To reset credentials just remove the gdrive config folder with a shell command from a code block
rm ~/.config/Google/DriveFS/ -rf
I ran into a similar problem where I clicked on the wrong account for Google Drive authentication. None of the files I needed to access were available, and I couldn't figure out a way to revoke a token by the comments above. I tried both restarting the runtime and changing from GPU to TPU. When I tried the latter, it worked and the authorization prompt returned. However, I'm not sure if it worked or just reached the token refresh time.
I factory reset my runtime and was able to get it to accept a different credential.
Runtime -> factory reset runtime

Installation an application in Drive

I search to install an GAE application in Drive (sample DrEdit with new API TR). All is OK, but I can not properly configure the "Google Drive SDK" (Part: Drive Integration) and the field "Install URL".
See screenshot (here: https://docs.google.com/file/d/0B6UEJFMrvusLY01XcHlXd0Fib2M/edit?ups=drive_web)
example of error:
Error :redirect_uri_mismatch
The redirect URI in the request: https://pcop-gd01.appspot.com did not match a registered redirect URI
Thank you for your help
Install URL should be added to "Redirect URIs" in API Access section to resolve this error. There can be multiple Redirect URIs delimited by new line character.

Google Drive DriveCommandLine sample app not working?

Is the Google Drive API sample command line app (DriveCommandLine) currently known to work? I have downloaded the Java client library, and compiled the sample application (inserting my application's client ID and secret created by specifying "installed application" and "other"). It runs and informs me to access the following link in a browser:
https://accounts.google.com/o/oauth2/auth?access_type=online&approval_prompt=auto&client_id=MY_ACTUAL_CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive
(Obviously with my actual client ID there.)
This successfully provides me with an authentication code. When I enter this at the application's prompt, then at the line:
File file = service.files().insert(body, mediaContent).execute();
I get the exception:
Exception in thread "main" com.google.api.client.http.HttpResponseException: 401 Unauthorized
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:978)
at com.google.api.client.googleapis.media.MediaHttpUploader.executeUploadInitiation(MediaHttpUploader.java:338)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:252)
at com.google.api.services.drive.Drive$Files$Insert.executeUnparsed(Drive.java:309)
at com.google.api.services.drive.Drive$Files$Insert.execute(Drive.java:331)
at DriveCommandLine.main(DriveCommandLine.java:56)
Investigation shows that the GoogleCredential returned has all elements set to null (which seems wrong).
The version of the Drive API client that I am using is "v2-rev5-1.7.2-beta", which is the one currently pointed to on the quickstart page here:
https://developers.google.com/drive/quickstart
I am compiling and running with this JAR and all the ones in the "libs" subdirectory in the classpath (the quickstart page refers to adding source JARs to the classpath which, obviously, dosn't work).
Can anyone shed any light on what might be going wrong here?
Thanks!
The link in the Quick Start is outdated. Try downloading the Drive SDK from the following link: http://code.google.com/p/google-api-java-client/wiki/APIs#Drive_API
See if that makes a difference for you. I have the DriveCommandLine app running fine.
You need to download JSON file from the API access page at
https://cloud.google.com/console.
Rename this json file as "client_secrets.json"
Copy this json into your project folder or more specifically copy it
into "src/main/resources". (This file contains the clientID and secrets). If the file is already present in the folder then replace it.
Now run the project. You will be redirect to Google Drive's "allow
access" page.
PS - json file must belong to an "Installed Type Application" because this is a commandline sample and runs locally.