通过JavaScript访问Microsoft Graph API [英] Accessing the Microsoft Graph API through JavaScript

查看:104
本文介绍了通过JavaScript访问Microsoft Graph API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个可与Microsoft Graph API一起使用的JavaScript示例.虽然我发现 https://github.com/OfficeDev/O365-Angular-Microsoft -Graph-Connect ;我不明白.我需要成为AAD管理员才能正确注册吗?我只是组织的Office365租户的普通用户.

I am looking for a JavaScript example to play with the Microsoft Graph API. Although I have found https://github.com/OfficeDev/O365-Angular-Microsoft-Graph-Connect; I don't get it to work. Do I need to be an AAD admin to get it properly registered? I am only a regular user of my organization's Office365 tenant.

我在 http://graph.microsoft.io/app-registration. 我都通过1)当前的注册工具和2)新的注册门户注册了该应用程序.两条路由都为我提供了唯一的clientId. 当我尝试通过clientId 1运行Angular示例时,出现以下错误:

I have used the wizard at http://graph.microsoft.io/app-registration. I both registered the app via 1) the current Registration Tool and 2) the new Registration Portal. Both routes provided me a unique clientId. When I try to run the Angular example via clientId 1 I get the following error:

AADSTS90093: Calling principal cannot consent due to lack of permissions.

并且通过clientId 2我收到以下错误:

And via clientId 2 I get the following error:

Application '<clientId>' is not supported for this API version.

您的指导是什么?

推荐答案

在此处完全同意Waldek的观点-这是开始构建应用程序时的绝佳建议. OK-您可以尝试在此处列出的3个注册门户网站 http://graph.microsoft.io/app-注册.在以下每个方面添加更多详细信息:

Totally agree with Waldek here - this is great advice when getting started building your app. OK - there are 3 registration portals you can try as listed here http://graph.microsoft.io/app-registration. Adding some more details on each of these below:

  1. Office在此处构建的轻量级版本: http://dev.office.com/app-registration 可能是最容易使用和入门的,再加上使用该经验,它将使您有机会下载使用您选择的语言的工作样本(应该选择JS).
  2. Azure管理门户- https://manage.windowsazure.com .该门户要求您具有Azure订阅,然后才能使用它.这是一个重量级更大的门户,但是它确实允许您完全自定义应用程序注册.
  3. 新"应用程序注册门户: https://apps.dev.microsoft.com/Disambiguation?ru=https%3a%2f%2fapps.dev.microsoft.com%2f .这是对我们身份平台更新的预览的一部分,该平台支持使用Microsoft帐户或工作/学校组织帐户的融合身份验证登录,并允许您的应用获取令牌来调用支持消费者或商业帐户的API.这是用于聚合身份验证的授权和令牌端点的v2. Microsoft Graph DOES支持注册为融合身份验证的应用程序.您遇到的第二个问题(此版本不支持clientId)可能是由于您的应用程序(仅v2身份验证端点支持的新的融合身份验证应用程序)试图从v1身份验证端点获取令牌.请在此处参考有关聚合身份验证的文档: http://graph.microsoft.io/docs/authorization /converged_auth .
  1. The lightweight one that Office built here: http://dev.office.com/app-registration which is probably the easiest to use, and get started with, plus using that experience, it'll give you the opportunity to download a working sample in the language of your choice (JS should be an option).
  2. The Azure management portal - https://manage.windowsazure.com. This portal REQUIRES that you have an Azure subscription before you can use it. This is a more heavyweight portal, but it does allow you to fully customize your app registration.
  3. The "New" app registration portal: https://apps.dev.microsoft.com/Disambiguation?ru=https%3a%2f%2fapps.dev.microsoft.com%2f. This is part of a preview of an update to our identity platform that supports converged auth sign in with a Microsoft account or a work/school org account, and allows your app to acquire a token to call APIs that support consumer or commercial account. This is the v2 of our authorization and token endpoints for converged auth. Microsoft Graph DOES support apps registered for converged auth. The second issue you got (clientId not supported for this version), was probably due to your app (a new converged auth app that is only supported by the v2 auth endpoints) trying to acquire a token from the v1 auth endpoint. Please refer to the documentation on converged auth here: http://graph.microsoft.io/docs/authorization/converged_auth.

希望这会有所帮助,

这篇关于通过JavaScript访问Microsoft Graph API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆