Created by Microsoft Corporation, 2017. Provided As-is without warranty. Trademarks mentioned here are the property of their owners.
DEMO: https://onenoteapisamplegraph.azurewebsites.net
- This is a small sample that shows how to use access OneNote resources via the Microsoft Graph API from an ASP.NET server.
Tools and Libraries you will need to download, install, and configure for your development environment
-
- Click on “How to Install a Specific Release of Visual Studio”:
- Click on “My.VisualStudio.com”:
- Download Visual Studio Enterprise 2015 with Update 3 (logged in with a MSFT account)
After you've set up your development tools, and installed the prerequisites listed above,...
- Download the repository as a ZIP file to your local computer, and extract the files. Or, clone the repository into a local copy of Git.
- Open the project (.sln file) in Visual Studio.
- It is highly recommended that you get your own client ID, secret and redirect uri and copy it into Config.cs. You can get your own appid, app secret and redirect uri here
- For local development, the sample uses http://localhost:5001/msgraphoauthcallback as a redirect URI. For production, you should change this to point to your application's domain. >Note: Chrome and Firefox do not allow cookies to be set on localhost, and thus authentication will not work on these browsers during development if you choose to redirect to localhost.
- Make sure you have selected the "OneNoteApiSample" configuration when launching the app locally. See screenshot.
- Build and run the application (F5)
You can find additional documentation at the links below.
- Create Pages:
- Query and Search Pages:
- Manage Notebooks and Sections:
As a sample, and for simplicity, this sample does not follow best practices for an application in Production. If you intent to ship this code, we recommend doing the following:
-
Never check in app secrets to your repository
-
Require HTTPS throughout your site
-
Don't store unencrypted refresh tokens in cookies
-
NuGet packages used in the sample. These are handled using the package manager, as described in the setup instructions. These should update automatically at build time; if not, make sure your NuGet package manager is up-to-date. You can learn more about the packages we used at the links below.
- Newtonsoft Json.NET package provides Json parsing utilities.
- Other Nuget packages from Microsoft, listed in project.json
Date | Change |
---|---|
May 2017 | Updated to utilize the Microsoft Graph v1.0 base URL for OneNote resources |
March 2017 | Updated to utilize the Microsoft Graph API endpoints. |
January 2017 | Initial public release for this code sample. |
- Visit the dev.onenote.com Dev Center
- Contact us on StackOverflow (tagged OneNote)
- Follow us on Twitter @onenotedev
- Read our OneNote Developer blog
- Explore the API using the Graph Explorer
- API Reference documentation
- Known Issues
- Getting Started with the Microsoft Graph API
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.