I would like to edit a OneNote NoteBook which is stored in a SharePoint Document Libary via a C# Console Application (because i want to use it to batch input pages into a notebook form a Windows 7 machine).
Url looks like this:
http_s://COMPANY.sharepoint.com/sites/SITE_ID/Documents/_New%20Tool/NOTEBOOK_NAME?d=SOME_ID
So i found this documentation for the OneNote REST API: One Note Api, and i have two questions:
How do i get/request the Bearer Token? SDKs for this seem to be only available for Universal Windows Applications
How do i get the correct API URI? As it states here i need some IDs for the URI, but i do not know which ones to use.
If anyone has any "quick start code" to begin with or a blog post, that would be great. The official examples on GitHub do not seem to be fitting my needs...
If you want to get a Bearer token from a console app, here are your options:
Get a token from somewhere else (e.g. another app that gets tokens) and temporarily copy it to your console app
Display (via a web control/browser) the sign in flow and extract the token from it into the console app. The user has to see the sign in UI at least once - there is no way around this unfortunately. The best example I can find of this is the following: https://github.com/googlesamples/oauth-apps-for-windows/tree/master/OAuthConsoleApp. You'd just have to change the URLs/scopes/AppId.
I'd suggest going with (1) or a different route (windows universal app), but if you do need it to be a console app... you'll need to essentially show a web control/browser with the sign in URL, then parse the code out of it once the user has signed in (or have the user paste it in).
Once you have the bearer token, you can read our blog post on how to use FromUrl to extract/edit content from a site.
Related
Using the DocuSign code-examples-csharp, you can export Room data to JSON. I need to batch export Room data using a C# console app without using the website. I'm unclear how to convert this web application to a console app. Are there examples of this somewhere?
First off, for a console app you will want to use JWT. The C# repo you can use JWT, so confirm this is working for you. With JWT there's no need for user to login.
You can then take the Auth Code from JWTAuth.cs and the example code from ExportDataFromRoom.cs and add them to your console app.
This should work if you also include the configuration information for auth.
We soon plan to add the Rooms API to the VS Extension that will make this even easier.
I read the OneNote Api Documentation https://dev.onenote.com/docs
But I don´t understand how to make a request to the OneNote API with c# web application in order to get all the pages in my OneNote.
I already got the Application Id, Application Secret Id and Redirect URL, but i don´t know where do I have to use them, because I have never done and http request and the documentation only provide the following: https://www.onenote.com/api/v1.0/me/notes/pages, so I don´t know how to send the id´s, redirect url and Authorization: Bearer.
Could you provide me the specific code to get a successful connection to OneNote API using Application Id, Application Secret Id and Redirect URL.
And the code structure to make a http request in order to get all the pages, notebooks, etc
I would appreciate if you could help me with this.
I would recommend using Microsoft Graph instead of the standalone OneNote API. Microsoft Graph includes support for OneNote. There is also an SDK for .NET available. There are also code samples for ASP.NET, UWP and Xamarin.
Before you can use the Graph API (or most any REST API for that matter), you will need to obtain an authorization token (i.e. the bearer token you referred to in your question). There are libraries available for simplifying this process. Behind the scenes, these libraries are executing an OAUTH 2.0 flow. You can read about what is going on under the covers here.
I believe the link they have on the OneNote Dev page is broken. The team has put together a public repository that contains a bunch of sample code in a myriad of languages including C#.
This is the main repo
Web API (ASP.NET Core) Repo
I believe the easiest way to understand these concepts is to look at sample code that does authentication. I recommend this sample:
https://github.com/OneNoteDev/MsGraph_OneNoteApiSampleAspNetCore
Btw - the demo is here: https://onenoteapisamplegraph.azurewebsites.net
Thank you everyone I have Checked all the links that you provided me and they were very useful, I did a connection to Microsoft Graph with the authorization token and I got access to my OneNote pages.
Thank you for your help.
I am writing a ToDo list Winform application and I would like to use the the One Note API in order to save the information about the tasks in the user Microsoft account.
So I browsed the One Note API documentation but after a few hours of research I did not manage to find a good entry point.
I understand that the first step for me would be to sign the user which is described on this page:
https://msdn.microsoft.com/en-us/library/hh826543.aspx
The thing is that the different ways of achieving that step don't seem suitable for a Winform client application, maybe I should use the rest API ?
I have been looking for a .NET code example but have yet to find any so I'm quite confused right now...
Thanks for any help !
You can use the OneNote API - signing in can be achieved by using a webcontrol and having the user follow the sign in flow there. Unfortunately we don't have any sample code for winforms, but the auth flow in our NodeJs sample for the OneNote API should be similar.
https://github.com/OneNoteDev/OneNoteAPISampleNodejs
You could also (assumming the user has OneNote installed) use the OneNote interop libraries to interact with OneNote and store/retrieve your data there.
How To Write To A OneNote 2013 Page Using C# and The OneNote Interop
You might also want to try developing a universal app instead of a windows forms application:
https://github.com/OneNoteDev/OneNoteAPISampleWinUniversal
I know I have seen apps that log me in using Facebook but never present me with an authorization screen. I can not, for the life of me, figure out how to do this with Windows Phone 7. The best I have been able to get is using the Facebook for C# SDK to get the authorization screen in a WebView. This looks hideous and the page does not even appear to be mobile ready.
I have searched high and low for an answer and have found nothing. Wondering if anyone can point me in the right direction to getting this to work?
Yes, I also saw this kind of apps (e.g. Spotify prompts you to enter your Facebook account credentials rather than using the normal authorization flow). My best guess is that they either some kind of premium partners and have access to some private APIs or they use custom authorization flows (e.g. when you authorize an app on a website, the system saves authorization key in the database. The same app id/secret is then used in Windows Phone app and all you need to do is to type in your email/username in order for the system to locate authorization key that was saved earlier).
I also don't like the approach of displaying Facebook login/auth using WebBrowser control (mostly because of UI inconsistency) but I'd say that this is still the way to go in most cases (because this is the official and recommended way of authorizing the app and all other approaches seem hacky for me and also have their disadvantages).
You will want to be using the "server-side authentication" approach. The following document describes how it works: Server-side authentication (read also OAuth Dialog documentation for how to configure the authentication dialog). You can change the way the UI looks by passing a display parameter (either to touch or wap).
Please note that display=touch is currently broken in Windows Phone - Facebook always falls back to wap which is deprecated and will be removed as per July 2012 update (corresponding case: Facebook API can't be used with Windows Phone apps). It's also among known issues on Facebook C# SDK project page: Facebook C# SDK - Known issues.
Hope this clarifies things a bit.
Ultimately I want to create a desktop app that allows users to update their own status, view status' of their friends, update pics etc. - basically a lot of the functionality the facebook website provides. Through looking through some tutorials and sample projects it seems that an app must be created for the facebook account. Now is this the facebook account of the developer (i.e. mine) - which will provide an API key that will allow any other user to log in?? Does every desktop project need to authenticate the user through a facebook dialog window to take the users' credentials?? Where does OAuth fit into this?? If anyone can shed any light as to the structure of the facebook api and the ways in which I can grant this functionality from say a WPF C# app for example I would really appreciate it.
EDIT: Before complaints of a potentially huge question or too 'vague', my question is specific to the integration/use of the facebook API in desktop applications - not how to then retrieve status feeds etc. I'll work that out myself.
Per Facebook documentation, all desktop apps will need to implement some form of web browser integration, whether embedded within the desktop app or controlled.
See: http://developers.facebook.com/docs/authentication/
Desktop Apps
Our OAuth 2.0 implementation does not include explicit desktop app
support. However, if your desktop app can embed a web browser (most
desktop frameworks such as .NET, AIR and Cocoa support embedding
browsers), you can use the client-side flow with one modification: a
specific redirect_uri. Rather than requiring desktop apps to host a
web server and populate the Site URL in the Developer App, we provide
a specific URL you can use with desktop apps:
https://www.facebook.com/connect/login_success.html.
Don't worry it took me two solid days of trial and error and re-re-reading of the documentation on authentication to finally "get" it.