angular - 使用 Oauth2 从 Outlook 日历 API 获取代码
问题描述
我正在使用.net core 和 Angular 使用日历 API。我使用 Google Calendar API 完成了所有步骤。现在我想使用 Outlook 日历 API 来完成。所以首先我需要一个Angular中的函数,这样我就可以连接到我的帐户并获取一个代码(Oauth2),我将在后端使用它来获取我的令牌(因为我想在我的数据库中注册它们)。好吧,这是我使用 Google API 的功能
handleAuthClick() {
let self = this;
gapi.auth2.getAuthInstance().grantOfflineAccess()
.then(value => {
const optionsParams = {
params: new HttpParams()
.set('code', value.code)
};
self.http.get("http://localhost:59933/api/UserCode", optionsParams)
.subscribe(data => {
console.log(data);
})
});
}
我想我可能需要函数或库中的这个链接?任何人都可以帮助使用 Outlook 日历 API 的功能吗 谢谢
解决方案
建议使用Microsoft Graph API来访问包括 Outlook 在内的 Microsoft 365 服务。
对于 Angular,您可以参考教程:Microsoft Graph 和 Angular 入门。它在 Angular 中提供 SDK 和代码示例。
GitHub 上还有几个 Angular 示例:https ://github.com/search?q=angular+sample+user:microsoftgraph&type=Repositories
此外,您的链接显示使用授权代码流获取 Microsoft Graph API 的访问令牌(范围是https://graph.microsoft.com/user.read
),您可以在基于 javascript 的应用程序中使用隐式流。
推荐阅读
- javascript - Chrome 扩展 - 访问 IndexedDB 的后台脚本(无存储)
- python - Pygame 窗口打不开
- c++ - Bazel:相对本地路径作为 http_archive() 中的 url
- powershell - ImportSystemModules 的目的是什么?
- python - 对 django 关系感到困惑
- uipath - 从网页中提取数据到 Excel
- excel - VBA:xmlhttp响应粘贴有时会省略标签?
- swift - (Swift) 将数据从 UITextField 保存到 Firebase Firestore
- arrays - 在 Query() 函数中更改特定列中所有单元格的文本
- javascript - 在 v-for 内的 vue js 中编辑状态