I've been following Google's documentation to share files on Drive: Share Files
If I upload a file to Google Drive from the Google Drive interface, then try to share this file from my webapp, i get the following error in my javascript console:
in chrome:
Refused to display 'https://drive.google.com/share?id=0B6UmN_AivG7SLWVYakF2Rk1CdDg&foreignServi…=postMessage&appId=958414147877&embedOrigin=http%3A%2F%2Fsandbox.velop.org' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
in firefox:
[14:04:41.157] Load denied by X-Frame-Options: https://drive.google.com/share?id=0B6UmN_AivG7SLWVYakF2Rk1CdDg&foreignService=explorer&shareService=explorer&shareProtocolVersion=2&command=init&subapp=10&popupWindowsEnabled=true&shareUiType=default&rand=1370585078609&theme=2&client=postMessage&appId=958414147877&embedOrigin=http%3A%2F%2Fsandbox.velop.org does not permit cross-origin framing.
Now the weird thing is if I create the file from my webapp and upload to Drive through the api, I am able to share the file without problem.
Even stranger, it is enough that I open the file once from within Drive ( I have installed the webapp in my Drive so I can open files using my webapp) to be able to share it, even if later I don't use Drive to open the file anymore.
Any idea what could be causing this kind of behavior?
In my Drive SDK console, I set the Open URL to: http://sandbox.velop.org/my-google-drive/detail
When I open the file in Drive using my webapp, Drive thus redirects me to: http://sandbox.velop.org/my-google-drive/detail?state=%7B%22ids%22:%5B%220B6UmN_AivG7SLWVYakF2Rk1CdDg%22%5D,%22action%22:%22open%22,%22userId%22:%22105908447865504163566%22%7D (able to share)
When I open a file in my webapp, the URL is like: http://sandbox.velop.org/my-google-drive/0B6UmN_AivG7SLWVYakF2Rk1CdDg/detail (able to share only if opened from drive once before)
EDIT:
I realized this is the standard behavior for Google Drive API as described here:
When users approve these scopes, the app is installed for the user, with access to files that the user creates or opens with the app.
Is there a way to allow the app to open / write any file?
I thought that using the https://www.googleapis.com/auth/drive scope when registering my app would allow me to do this, but doesn't seem to be the case..
I am running into exactly the same issue.
My app is requesting the full drive scope (so the app should have access to all files).
But sharing only works if the file has been opened by the user from the drive before.
There seems to be some magic "while-listing" of files that have been opened from drive.
When accessing a file that has not been opened from drive before I get...
Refused to display htps://drive.google.com/share?id=0534534543iTEhYamxfUnc2MnM&foreignServi…ent=postMessage&appId=46459361793&embedOrigin=http%3A%2F%2Fwww.editey.com' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
...which obviously is misleading as the share button is not in a frame.
Opening the give url in a new browser tab gives a hint to the real root-cause:
Application '3453459361793' is not authorized to access document "0B0o5345345DAc_SiTEhYamxfUnc2MnM".
My app should have access to the document but it looks as if the "share dialog" acts as a separate app that will only allow access to files that have previsouly been opened from drive.
For security reasons drive will not let you use that dialog unless you're at the URL specified in by your "Open URL".
Your current URL http://sandbox.velop.org/my-google-drive/0B6UmN_AivG7SLWVYakF2Rk1CdDg/detail != http://sandbox.velop.org/my-google-drive/detail
So you might want to change your URL structure. Maybe something like http://sandbox.velop.org/my-google-drive/detail?open=B6UmN_AivG7SLWVYakF2Rk1CdDg
This is real pain in the neck, especially when developing on a different domain.
Related
Google Chrome allows you to preview local PDF files in the browser like pictured below:
I am working on an extension that takes whatever PDF is in the browser preview and opens it in my custom editor/markup tool.
I have been successful in loading PDFs from remote URLs because I can just send the remote URL to my server, download it there, and open the PDF in my app using PDFjs.
How can I accomplish the same functionality for local PDF files?
I have looked into possibly using javascript to create a File object from local PDF files but Chrome doesn't allow access to the local file system.
I am hoping to accomplish this functionality by the user just clicking my extension icon, similar to the popular extension, Kami.
you need to add permissions to your extension:
"permissions": ["file://*/*"]
to ensure that you have permissions for local files, use:
chrome.extension.isAllowedFileSchemeAccess
P.S. have a good day and do not use upwork for these type of questions :-D
I have a ASP.MVC app running in my company's domain. I would like to make links to Word, Excel or even to folders. For example I would like to allow user to access a project folder on public drive or Office document. Files and web app are on different servers, but in same domain.
The problem is that all modern browsers block access to local files. (Chrome throws an error saying "Not allowed to load local resource: file://..."). IE we are currently still using does allow that, but I can't rely on this.
How to tell the browser that it is safe to open those links?
I read about an option to serve .url files to user with link to file/folder. The downside is that I'd fill users temp folders with .url files. And also while I was testing this, I couldn't make changes to .url file after I saved it. Even removing the file doesn't help. It looks like windows stores it somewhere.
Another option was to make an a-tag with href like "data:text/plain;charset=utf-8..." and offer user to download .url file that way. But it was somehow not working for me.
Please help.
Thank you.
i´m searching for a way, that a google drive app opens a local url from my extension.
I only know the way, that my extension redirects after opening a file with my extension to an web URL.
I need a way, to open an javascript (e.g. index.js) from the folder of my extension, that is installad on the users pc.
Does somebody knows a solution?
The background of this workaround: No private data should go to my webserver. All actions should be handled over javascript in the browser of the user.
I have several users on an intranet and all have a mapped drive to server (E:).
All users are on Win7 and use FireFox.
I have used XAMPP on the server to allow users access to MySQL files using PHP.
They currently use windows explorer to open a folder on (E:) so save/modify files (jpgs, docs etc.).
I want to put a link in the html to open this folder for them.
I've spent some time researching this with varying amounts of success and I have found out that this may have security issues such as...
A web application does not have access to the local machine's filesystem
but these are all clients accessing the same server on a local intranet.
I can type...
file:///C:/MyFolder/MySubFolder/
in my browser address bar which opens a page with a directory listing of the files in the sub folder. Not ideal but half way to a solution!
But the script below does not work...
window.open("file:///C:/MyFolder/MySubFolder/");
Can this be done?
you path would be
window.open("http://localhost/MyFolder/MySubFolder/");
or
window.open("http://IP/MyFolder/MySubFolder/");
use absolute path for this
Firefox will work if the link is in its own mangled form using five slashes (file://///C:/MyFolder/MySubFolder/) and the user has disabled the security restriction on file: links in a page served over HTTP.
check this post for more info
Please I am new to building Chrome Extensions. After the user installs the extension, I want them to configure it by specifying a directory where the app can save files. I want to do this by opening a save file dialog so they can browse to the folder of their choice. How do I do this?
The answer is that there is no means in the Chrome Extension API to write files outside of the sandboxed file system provided by Chrome. This could theoretically be done by writing an interface in C and then call that, but so far I have not yet seen a successful implementation.