office 365 api generate a guest link for MyFiles - api

I am trying to access from an MVC application, the OneDrive files from my office 365 account.
What I need is to give my application user the possibility to edit a .docx file, in their browser.
I used Office 365 APIs Preview, to get the list of files, and their properties, but I don't know how to allow the user to edit that file in his browser.
A solution to this problem could be to share the file with different user of my application, by creating a guest link.
From the office365 portal this is a simple task:
- OneDrive, select the file -> manage -> share with -> get a link, the link can have read only or read write rights.
I don’t know how to create this link from the APIs.
Can you please tell me how can I generate this guest link or if there is a different solution to this problem.

In short, I don't think this can be done in a supported way.
There is a real risk that if you figure out the URL structure, that the structure could change. I suggest that you make a feature request by using UserVoice. It would be preferable that the REST API and the client objects construct this URL for you.
With that said, if you take the sharing link, and place it into a browser window, the link will redirect to Word Online with the document in the browser. Take a look at the structure of the URL in the Word Online browser window. You could use that as a template, and along with the information from the File.Url property from the Office 365 API Preview, you may be able to put together a URL to that file. Expect that this approach would not be supported and would be subject to URL structure changes.
If other people find that this would be a useful feature, please use UserVoice to let us know.

Related

How to download a file from a SharePoint though a website button?

I hope all is well,
I have a webpage that has a button and a SharePoint library.
Once the user clicks the download button, the document will be downloaded from SharePoint with a watermark of the user trying to download this file.
Additionally, I need to manage who can access or download the file.
Therefore, the main points to consider are:
User authentication to the SharePoint document library
Pulling the document from the website itself
Watermark feature
Thus, what is the most effective practice to achieve that and what should I use?
Thanks in advance
oh man, this is really an open and not quite detailed question 😟. Could you provide more context? what language are you using? have you already tried something and what is failing?
For now, the only help I may provide you is just general info πŸ™‚:
User authentication to the SharePoint document library
if you are extending SharePoint or M365 with a SPFx solution you do not need to worry on auth. If it is totally aside I would recommend checking
https://learn.microsoft.com/en-us/graph/auth/auth-concepts
I would strongly recommend checking microsoft-graph-toolkit there is a mgt-login component
https://learn.microsoft.com/en-us/graph/toolkit/components/login
again here I would also recommend using MS Graph and endpoint like https://graph.microsoft.com/(version)/sites/(site-id)/drive/(drive-id)/items/(item-id)/content
I guess this is a very similar topic: Sharepoint Graph API download file from Document library that are not listed as drive ("Site Pages" and others)
Watermark feature
as for this I would take a look at Microsoft 365 sensitivity labels feature and read more about it here
https://learn.microsoft.com/en-us/microsoft-365/compliance/sensitivity-labels?view=o365-worldwide#what-sensitivity-labels-can-do
I hope this will be of any help. For sure it is a good start πŸ™‚

How can I use M/S Graph APIs to read Sharepoint lists

I see from other Users' questions that this used not to be possible but other research suggests it now might be; I'm using Graph Explorer and have started with this generic URL: https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/. I'm logged in as a User who is an Owner of the Sharepoint site I'm going after. But so far, I have not been able to find, much less see the contents of any Lists that I know are there in the site. Q1: Is this even possible (now)? Q2: How - or - what am I missing?
Yes this is possible but the graph API doesn't rely on the permissions as defined on SharePoint and might explain why you are not seeing the lists you own via the graph api.
You will have to setup the necessary Azure AD permissions on your app to access SharePoint list and items via the graph api.
As shown below, i can read data from the specified list based on permissions already consented to.

How to View a Google Spreadsheet Doc as a PDF

I would like to know if it's possible to view a Google Spreadsheet Doc as a PDF without first manually converting it as a PDF? I don't want to share a link directly to the spreadsheet, I want to share a link to a PDF version of it which ends up looking better (in Print View rather than Spreadsheet Document View)
I know I can Print > Save as PDF, then download to local machine, then upload and save somewhere on my server. But is there is a way to be able to view the spreadsheet as a PDF.
I have Google'd this and found nothing. The best I could come up with is the Google Document Viewer (https://docs.google.com/viewer) but that does not seem to give mt the option I am looking for. Further, I do not want to install any Chrome plugins, etc. because I want to be able to share a link to the PDF with people but not have to have them install a plugin to see the doc.
Unfortunately, what you are trying to do and the way you are trying to do it is not a capability within Google Docs. Sorry.
I think the best way is to use Google Drive API to write own script that will do this job. I mean:
You have a web server
Write a simple method in any web technology, such as PHP, Python, Java, C#, whatever you like and your server is able to serve. This method is connected to the google drive through it's API to your account, knows which spreadsheet to take care of and how to understand the columns. This spread should be parsed to HTML and with some popular tool (proper for your programming language or server's operating system) you create the PDF. The method should create HTTP response with header type: application/pdf.
You provide interested people with the link under which your method is available.
I guess this reference should help you to use Google API:
How to download the resources:
https://developers.google.com/drive/web/manage-downloads
How to convert (i.e. to PDF) and open the resources in your own application:
https://developers.google.com/drive/web/integrate-open#open_and_convert_google_docs_in_your_app
I hope this helps.

Can you create Google Forms from Google Docs in an application?

I am thinking about app that will use google form and I need to create forms from that app. Is there a way how can I create form in google docs without using website but through some api or some other way?
I can offer an idea for a solution using Google App Script.
Since the beginning of 2013 you can create new forms using the App Script Forms Service API quite easily.
var form = FormApp.create(title)
.setDescription(description)
.setConfirmationMessage('Thanks for responding!')
;
The problem now is how to get that App Script running from your non App Script code.
You can use App Script to create a Web App that reacts to HTTP GET requests.
So putting it together, you may be able to create an App Script Web App that reacts to a GET request and when it gets the right URL parameters, it creates the form.
(Nov 2020) Yes, it is possible to programmatically create Google Forms. You can do it with Google Apps Script using its Forms service. You can also extend the code to read in the contents from Google Docs (with Apps Script's Document service) and use it for the creation of Google Forms.
I created a Google Workspace (formerly G Suite) Add-on, which you can think of as a Google Docs extension, called GFormIt. Its original purpose was intended for teachers to write exams/quizzes, possibly with answers, in Google Docs, then automatically convert them to Google Forms to distribute to students who submit their answers into Google Sheets (the destination for Google Forms submissions).
Furthermore, if you (the teacher) provided answers to your test questions, GFormIt would also auto-submit your answers to the Sheet as if you were a student. If you do that, and use a tool like Flubaroo to grade the exam, you could designate your row in the Sheet as β€œthe answer key.” You can learn more about how it works, including viewing a short video, at the GFormIt page linked above.
This Google Docs add-on, along with others for Google Docs, Sheets, Slides, Forms, etc., are all certified/validated by Google and available for free to anyone from the Google Workspace Marketplace. (However, your admins may have to grant permissions for you to try to install them to your corporate Workspace account.) If interested in building your own add-on, please see the developer documentation and perhaps some of my introductory videos to get started, the most relevant being the one linked to at the top of this answer.
Apps Script is a serverless Google technology, meaning you write your code (using JavaScript) in the browser, and it is hosted by & executed on Google servers. If you wanted to create your own web app (and hosted anywhere), you would have to wait for a Google Forms REST API which does not exist at the time of this writing. (If we ever launch one, you'll find its documentation at https://developers.google.com/forms along with the others like Sheets https://developers.google.com/sheets, Gmail https://developers.google.com/gmail, Drive https://developers.google.com/drive, etc.)
Earlier this year (Mar 2022) the new Google Forms Api graduated from Beta. It is more powerful that the previous versions and caters for two main use cases:
Automated form creation and editing: Enables automated form creation
and editing. Enables rapid form generation from large volume question
banks or other data backends.
Reaction to Form responses: The API also enables developers to build
automations for acting on incoming responses. Examples include
developing real-time dashboards or visualizations and triggering
business workflows based on response data.
We have used it to build an integration that Creates documents and slides each time a form is completed: www.portant.co/google-forms-to-docs and it works really well.
I think the other key use case looks like it would be a good fit for you and others looking for a solution like this.
Cheers, James
Sorry, the API doesn't support programmatically creating forms.

How to check if an email attachment has been opened

I am working on a study that sends people a PDF document with information about their health. The team would like to know if the person has actually opened the PDF document (a sign that they didn't just ignore the e-mail). I know that it'd be possible to do it with a link to an external file, but the users are much less likely to click on a URL and download it then they are to just view an attachment, and we don't want to do anything that might prevent the users from reading the information (we've already had people say they never received the message, and with further investigation they discovered they had, they had just ignored it).
Another option is to request a read report, but this is only useful if it doesn't annoy the user (ie it does it automatically when the email is opened instead of requesting them to send one). We're currently looking into this as well, but the ability to check if the attachment has been opened is a much better idea.
The email is generated in MS SQL and sent using the database mail system, and we have adobe acrobat pro, so creating scripts in pdfs is possible (although I'm not sure whether those scripts will be allowed to run).
Thanks
1) Dont include the PDF in the email, include a link to the PDF.
or
2) Include a javascript snippet in the PDF, which hits a per-user URL or includes IP address or something to track. This will only work if the user allows javascript, and if their pdf reader supports it.
See
http://ask.metafilter.com/153206/Is-it-possible-to-track-where-a-PDF-file-goes-once-in-the-wild
Since this was originally posted there has been a number of consumer tools that now let you track PDF's sent via a web link.
http://docsend.com , http://attach.io
and if you're sharing from Dropbox
http://orangedox.com
Much easier than having to script it yourself
At this time there are a number of tools available who offer attachment tracking service to their users. I am also using SalesHandy for attachment tracking and get the deep analysis of when & where your attachment is open.
Click to read more: https://www.saleshandy.com/document-tracking/