Coder Social home page Coder Social logo

isabella232 / sharepoint-add-in-jsom-crossdomain Goto Github PK

View Code? Open in Web Editor NEW

This project forked from officedev/sharepoint-add-in-jsom-crossdomain

0.0 0.0 0.0 33 KB

Use the SharePoint Cross Domain JavaScript library (CDL) to access SharePoint data from a remotely hosted web page without the need for OAuth tokens.

License: MIT License

Gherkin 7.39% ASP 23.97% C# 15.43% JavaScript 53.21%

sharepoint-add-in-jsom-crossdomain's Introduction

page_type products languages extensions description
sample
office-sp
office-365
javascript
contentType technologies createdDate
samples
Add-ins
OAuth 2.0
8/12/2015 1:15:58 PM
Use the SharePoint Cross Domain JavaScript library to access SharePoint data from a remotely hosted web page without the need for OAuth tokens.

Access SharePoint data with the Cross Domain JavaScript Library

Summary

Use the SharePoint Cross Domain JavaScript library (CDL) to access SharePoint data from a remotely hosted web page without the need for OAuth tokens.

Applies to

  • SharePoint Online and on-premise SharePoint 2013 and later

Prerequisites

This sample requires the following:

  • A SharePoint 2013 (or later) development environment that is configured for add-in isolation. (A SharePoint Online Developer Site is automatically configured. For an on premise development environment, see Set up an on-premises development environment for SharePoint Add-ins)

  • Visual Studio and the Office Developer Tools for Visual Studio installed on your developer computer

Description of the code

The sample includes an instance of an Announcements list with two sample announcements in it. The list instance is deployed to the add-in web. When the start page loads, JavaScript in the CrossDomainExec.js file, in the remote domain, makes an AJAX call to SharePoint to get the announcements and displays them on the page.

The page looks similar to the following.

The add-in start page with a table showing the result of searching on the term "SharePoint".

Note: The start page of the add-in, CrossDomainCall.aspx, is a plain HTML file. It has an "aspx" extension because when a remote start page in a provider-hosted add-in is opened by SharePoint, SharePoint sends it a context token in the body of the HTTP request. To do this SharePoint must send a POST request. But the IIS Express that is hosting the remote page when you are debugging will not accept POST requests to a resource with a .html extension.

The sample demonstrates the following:

  • How to use the key classes of the CDL to make calls from a remotely hosted domain to the SharePoint add-in web domain.

  • How to parse the JSON-formatted data returned from the SharePoint and how to display it dynamically.

To use the sample

  1. Open Visual Studio as an administrator.
  2. Open the .sln file.
  3. In Solution Explorer, highlight the SharePoint add-in project and replace the Site URL property with the URL of your SharePoint developer site.
  4. Press F5.
  5. After the add-in installs, the consent page opens. Click Trust It.
  6. The page opens that the JavaScript runs immediately.

Troubleshooting

For troubleshooting steps, visit the "Troubleshooting the solution" table in the cross-domain library documentation article.

Questions and comments

We'd love to get your feedback on this sample. You can send your questions and suggestions to us in the Issues section of this repository.

## Additional resources

Copyright

Copyright (c) Microsoft. All rights reserved.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

sharepoint-add-in-jsom-crossdomain's People

Contributors

davidchesnut avatar o365devx avatar rick-kirkham avatar supernova-eng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.