我正在关注博客(http://blogs.msdn.com/b/onenotedev/archive/2015/06/11/and-sharepoint-makes-three.aspx)以访问存储在Office 365 sharepoint租户中的一个便笺文件。我注册了我的应用程序并且能够获取令牌但是当我使用accessToken时访问以下URL
www.onenote.com/.../FromUrl(URL ='的https://*****.sharepoint.com/sites/“)
我总是得到401.知道出了什么问题吗?
答案 0 :(得分:0)
您的API请求中的身份验证标头似乎缺少“持有者”#39; OAuth令牌前的前缀。这就是为什么你得到401-Unauthorized响应的原因。 我们的Github repo在O365 auth上有代码示例,它可能是一个很好的参考资源。
答案 1 :(得分:0)
这是微软OneNote团队的Sharad。
我们在GitHub中发布了一个示例(本机)应用
github.com/OneNoteDev/OneNoteAPISampleWinUniversal
请查看文件 -
OneNoteServiceSamplesWinUniversal.Shared / OneNoteApi / O365Auth.cs
有资源Uri并重定向Uri。重定向Uri是您的应用程序控制,但资源Uri始终是相同的。
代码(原生应用):
private const string AuthContextUrl = "https://login.windows.net/Common";
private const string ResourceUri = "https://onenote.com";
// TODO: Replace the below RedirectUri with your app's RedirectUri.
private const string RedirectUri = "https://localhost";
_authenticationResult =
await AuthContext.AcquireTokenAsync(GetResourceHost(ResourceUri), ClientId, new Uri(RedirectUri), PromptBehavior.Always);
原生应用 - 看看这个blog。 网络应用 - 看看这个blog 我希望这有助于解决您的问题。随意使用提琴手追踪(请求/回复)。