简体   繁体   English

适用于我的Node.js应用程序的OAuth2和Microsoft Graph API?

[英]OAuth2 and Microsoft Graph API for my Node.js app?

I'd like to add an Office365/Graph Calendar integration to an existing Node.js app (hosted on AWS). 我想将Office365 / Graph Calendar集成添加到现有的Node.js应用程序(托管在AWS上)。 I've already done a similar integration with Google's Calendar, and it was trivial to get set up. 我已经与Google的日历进行了类似的集成,并且设置起来非常简单。 I'm not having nearly as much luck with the Microsoft version of things. 我对Microsoft版本的东西不太满意。

I've found at least 4 different ways to register an app (get a clientId and clientSecret), and I seem to get different errors for each of them, but can't get any to work properly. 我发现至少有4种不同的方法来注册应用程序(获取clientId和clientSecret),并且似乎每个方法都有不同的错误,但无法正常工作。

I think a large part of my problem is that I've never had to work in the MS ecosystem before, so I don't have a lot of the baseline knowledge that the documentation assumes. 我认为我的问题很大一部分是因为我以前从未在MS生态系统中工作过,所以我没有很多文档假设的基础知识。

I'm not looking to host anything with Microsoft - do I even need an Azure account? 我不想在Microsoft托管任何东西-我什至需要Azure帐户吗?

I'd like to allow any user with an Office365 account to connect it to my app - do I need to learn about Active Directory to do this? 我想允许具有Office365帐户的任何用户将其连接到我的应用程序-我需要了解有关Active Directory的信息吗? Does this part of it require Azure? 这部分需要Azure吗?

I've found instructions for using both https://login.microsoftonline.com/common/oauth2 and https://login.microsoftonline.com/common/oauth2/v2.0 for this, do I need to worry about which version I use depending on how I registered my app? 我已经找到了同时使用https://login.microsoftonline.com/common/oauth2https://login.microsoftonline.com/common/oauth2/v2.0的说明,我是否需要担心哪个版本我使用哪种方式取决于我注册我的应用程序的方式?

Microsoft Graph leverage Azure AD to authenticate and authorize users. Microsoft Graph利用Azure AD对用户进行身份验证和授权。 The doc refers as: 该文档指的是:

To get your app authorized, you must get the user authenticated first. 要使您的应用获得授权,您必须先使用户通过身份验证。 You do this by redirecting the user to the Azure Active Directory (Azure AD) authorization endpoint, along with your app information, to sign in to their Office 365 account. 为此,您可以将用户连同您的应用程序信息一起重定向到Azure Active Directory(Azure AD)授权终结点,以登录其Office 365帐户。 Once the user is signed in, and consents to the permissions requested by your app (if the user has not done so already), your app will receive an authorization code required to acquire an OAuth access token. 用户登录后,并同意您的应用请求的权限(如果用户尚未这样做),您的应用将收到获取OAuth访问令牌所需的授权代码。

So you need to register an Azure account for configure the Azure AD service. 因此,您需要注册一个Azure帐户以配置Azure AD服务。 Refer https://graph.microsoft.io/en-us/docs/authorization/app_authorization for more info. 有关更多信息,请参阅https://graph.microsoft.io/zh-cn/docs/authorization/app_authorization

Meanwhile, to implement Microsoft Graph in node.js application, you can refer the following code sample for your information. 同时,要在node.js应用程序中实现Microsoft Graph,可以参考以下代码示例以获取信息。

Matt, you can do this without an Azure account if you use the oauth2/v2.0 auth endpoint. Matt,如果您使用oauth2/v2.0 auth终结点,则可以在没有Azure帐户的情况下执行此操作。 When you do that, you can register on apps.dev.microsoft.com using a Microsoft account. 执行此操作时,可以使用Microsoft帐户在apps.dev.microsoft.com上注册。

See this tutorial for doing it with the Outlook REST API, which is similar to the Graph (in fact, for Calendar operations the calls and entities are identical). 有关使用Outlook REST API进行此操作的信息,请参阅本教程 ,该应用程序类似于Graph(实际上,对于Calendar操作,调用和实体是相同的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM