0
votes

What is the best method to get SharePoint list items from Office Web Addin using the credentials of the logon user?

We have migrated to Office 365, I am not sure whether i must authenticate on AD or Office 365, the Office Addin App will be deployed on SharePoint on Premise

I have tried rest services but I am not sure of how to pass the user token, for authentication.

function GetSharePointListItems() {
    $.ajax({
        url: "weburl/_api/web/lists/getbytitle('listname')/Items?$select=Title,ParagraphText&$filter=ParagraphText isnotnull ",
        type: "GET",
        Authorization: {"Bearer " + accessToken},
         headers: { "accept": "application/json;odata=verbose" },
        success: function (data) {
            if (data.d.results) {
                   OnSuccessSharePointData();
            }
        },
        error: function (xhr) {
            alert(xhr.status + ': ' + xhr.statusText);
            OnErrorSharePointData();

        }
    }); 

any ideas

1
Can you please clarify what you mean when you say you have tried rest services? Are you getting an error? - Rick Kirkham
Hi there I am getting an access denied error using rest services, - taps bops

1 Answers

0
votes

Your add-in does have to get authorization to SharePoint Online/Office 365. Asking "what's the best way" is pretty broad, so here are some starting points about auth to SP/O365:

(When you say that you will deploy the add-in on SharePoint on Premise, I assume that you mean that you will deploy the add-in manifest in a SharePoint corp catalog. Is that right?)