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)
Related
I need to get a shareable link to google drive photos and files. Do I need to know this method can be used for that or what can be used for that?
You can see the defined use for setRelay in Picker Class Reference:
PickerBuilder.setRelayUrl(string) - Set the relay URL, used for gadgets.rpc.
Picker.setRelayUrl(string) Specify a relay URL to circumvent cross-domain issues.
However to answer your question, you might be looking for webViewLink:
A link only available on public folders for viewing their static web
assets (HTML, CSS, JS, etc) via Google Drive's Website Hosting.
This property is returned from a successful API call like files.get or files.list.
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.
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
I'm looking for some clarification on accessing Google docs/Drive SDK via a Service Account.
I have everything set up in the API Console and I can successfully generate an access token via the JWT process and indeed I can issue requests to either drive SDK or the Docs List API to get a listing of documents. However, the document listing is always empty, I was expecting to see all the documents in my Google Drive. I am obviously not understanding fully what a service account gives you. If I upload a document via the Service Account then it does show up correctly, but is not visible in my Google Drive, it's as if the Service Account is a totally separate black box.
The reason I want to use Service Accounts is that I have a service running that needs to upload documents to various clients Google Docs accounts, without them having to go through the OAuth dance as there will be no UI interaction at all. Is this possible with Google docs. I was hoping that they could just send my the client_email and the certificate with the private key and I would be able to upload documents to that account.
Many thanks for your consideration
-Marshall
Not sure whether you need the answer anymore, but I just faced with the same issue, came to this post. Found one solution which works in my case, so sharing with everyone here.
The only integration point towards GoogleDrive in my case is document listing.
When I first created my service account, it didn't work as well (just empty list all the time).
What did I do to fix it:
Go to MyDrive UI https://drive.google.com/#my-drive
Checked all the documents I want to see on my website
In the top menu clicked "More"->"Share..."->"Share..."
In "Add people" section (new window "Sharing settings (N items)") I added service account email (format is "XXXXXX##developer.gserviceaccount.com")
Run document listing once again and got it working.
I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error:
"The authenticated user has not installed the app with client id ..."
Reading further, it seems I need to publish my Emacs application in the Chrome Web Store to get access to the Drive API. That doesn't make sense to me...I noticed that there is a FUSE project in development for Google Drive, which suggests that native development is possible. When I skimmed the code, however, I didn't see a Chrome Web Store component to getting it working.
Am I trying to misuse the API, or is there an route to make this work that makes more sense?
EDIT:
According to Ali Afshar, of the Google Drive team, installation is no longer required to use this API. So what follows may no longer be relevant, but will be left for historical purposes.
So, first off the API does not support application development in the sense that we are both doing it, I wouldn't use the word native though. The good news is I have been doing some research and Google Drive is really just a rebranding of Google Docs. So the Google Docs API could be a good choice as well for the same purposes.
Anyway, here's the steps to solve the error: "The authenticated user has not installed the app with client id ..." Which is a 403 error, for the sake of this answer. These steps assume you have set up an app in the chrome web store as is required, and installed it. I am working on my local machine too, with my project: http://github.com/tom-dignan/gdrive-cli which I have gotten past this error, so I think you should keep plugging away at your emacs version, because I think we can make this work.
a. Open the Google APIs console.
b. Confirm you've already enabled the apis under "API Access" both the API and SDK for Google drive should be enabled. There you get your client secrets/api keys and such. I am almost positive you've done this already, so go ahead to C. (this is here for others who may have missed it)
c. In the left navigation bar, under "Drive SDK" you will need to do the following:
Add a "Support URL" (required)
Add at least a small 16x16 application icon (required)
Add "OAuth Client ID (Required)" under Drive Integration (I was just tinkering and this seems to be the key field.)
Add "Open URL (Required) URL to open for your app from the google drive UI."
Check off "Multiple File Support"
Add some MIME types and file extensions, "text/plain", and txt for example
Add the the auth scopes:
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
Don't bother trying to add the auth scopes for Google Docs here, because it won't work. Google does not want us to use it that way because files that drive apps create should be private to that app. Integration with Google Docs will have to be separate.
Now I know you must be thinking "why do I have to add some of these..." It's because the form makes them required fields. In mine, I put a couple URLs that point to static HTML pages.
Once you've done the above, clean up your state and reinstall your chrome app. Then try your code again, and it should stop giving you a 403.