Installation an application in Drive - google-drive-api

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.

Related

what client_secret.json file is it required for google drive files access

I am getting this error:
File "/usr/local/lib/python3.7/site-packages/pydrive/auth.py", line 388, in LoadClientConfigFile
raise InvalidConfigError('Invalid client secrets file %s' % error)
pydrive.settings.InvalidConfigError: Invalid client secrets file ('Error opening file', 'client_secrets.json', 'No such file or directory', 2)
all I want is to list files and folders using pydrive !
I tried creating credentials but On consent page its showing unverified status.
from the credential page under OAuth 2.0 Client IDs tab I downloaded created credentials and downloaded crediential file secret_json_[.....].json file
Looking into the documentation for pyDrive:
Click ‘Download JSON’ on the right side of Client ID to download client_secret_<really long ID>.json.
The downloaded file has all authentication information of your application. Rename the file to client_secrets.json and place it in your working directory.
So probably you are lacking the last step of renaming the file and placing it in the working directory.
I tried creating credentials but On consent page its showing unverified status.
This should not matter at all, unverified just means that you are trying to access sensitive scopes and until Google verifies your application there would be an extra screen indicating that it is a unverified apps. Is okay for personal/development use.

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

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.

upload fail the google api after redirecting to localhost

After I run the following code from:
https://developers.google.com/drive/api/v3/quickstart/python
I get the link:
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=792377765624-8l03cnfmj1km5gd27227kuaem37okdip.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A41245%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&state=8xHuMrgWMisZa7Hww6HpIZrRdkRTjq&access_type=offline
I click it and get new pages.
I was not allowed to upload pictures here,sorry.
Because my score is low in stackoverflow
Finally, it tell me I can not connect to:
http://localhost:44637
Screenshots of the behaviour: https://blog.csdn.net/appleyuchi/article/details/102940981
According to the screenshots you provided and the url you are getting redirected to, the problem is that the Google account with which you downloaded the credentials file is not the same as the one with which you grant authorization to Drive. Both should be the same, because the credentials file contains information that identifies the account that downloaded them.
Check these for further information on the authentication process:
https://developers.google.com/identity/protocols/OAuth2
https://developers.google.com/identity/protocols/OAuth2WebServer

Install firefox os apps available on Marketplace using App Manager

I am trying to install App using App Manager in Firefox OS device. But my problem is I am unable to push any of the apps which are published on MarketPlace. It show that
The webapp manifest isn't a valid JSON file: SyntaxError: JSON.parse:
unexpected character at line 1 column 1 of the JSON data at:
https://marketplace.firefox.com/app/pacman-canvas can't be opened
So can anyone suggest some way to push the app to my device using App Manager only?
It's pretty easy. On the Marketplace page (in Firefox desktop) open the marketplace page for the app. Then open Devtools and select the Debugger. In the debugger, break in file iframe-installer.html, on this line:
installPackage(e);
Now click the 'Free' button, the debugger will break on this line. In the console you now type:
e.data.data.product.manifest_url
This will give you a URL. If the URL is located at someone else's webserver (like Pacman), e.g. http://pacman.platzh1rsch.ch/pacman-canvas.webapp, you can (in the App Manager) click 'Add hosted app' and paste the URL. However you will need internet on the phone the first time you use the app (because its hosted app).
If the URL is a Mozilla URL (https://marketplace.firefox.com/app/etc.), you can open the link in your browser. Open the file. You now have a JSON file in which you need to look for the package_path key. F.e. for Recorder it's
"package_path": "https://marketplace.firefox.com/downloads/file/258677/recorder-1.1.zip"
You can now download this ZIP file, unzip it in a folder, and add the folder as a Packaged app.
For apps in the marketplace, you best solution for getting them on the phone is to just use the marketplace app. That said if you own the app in the marketplace you should be able to look at the manifest url of the app using the edit listing marketplace button. If this is a hosted app you can you use this manifest url in the add hosted app entry box within the app manager to add it and then push it to phone. On another note you can debug the system apps by using the procedure described here:
https://developer.mozilla.org/en-US/Firefox_OS/Using_the_App_Manager#Debugging_Certified_Apps

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.