microsoft-graph-api - 像 Google 这样的更简单的 MSAL.js 身份验证?(不使用缓存系统)
问题描述
我真的在努力使用 Microsoft Graph 身份验证系统(与 Google Auth API 相比)。
我只想使用存储的令牌进行 API 调用(无需管理缓存系统或其他)。
这是我想用 Microsoft Graph 复制的一个简单的 Google 示例:
const { google } = require('googleapis');
const oauth2Client = new google.auth.OAuth2(
process.env.GOOGLE_CLIENT_ID,
process.env.GOOGLE_CLIENT_SECRET,
process.env.GOOGLE_CLIENT_REDIRECT_URI,
);
const auth = oauth2Client.setCredentials(googleOauthTokens);
// googleOauthTokens is stored on my DB and doesn't need to change,
// I got it from the oauth redirect callback using oauth2Client.getToken(req.query.code)
const calendar = google.calendar({ version: 'v3', auth });
const { data: calendarData } = await calendar.calendarList.list();
console.log(calendarData);
我希望使用 Microsoft 身份验证库 ( @azure/msal-node
) 完成类似的流程,而无需管理在ConfidentialClientApplication
.
为什么我们不能只使用结果msalClient.acquireTokenByCode(tokenRequest)
来设置凭据并开始使用 Microsoft Graph API?
我查看了 MSAL 的所有文档/常见问题解答,但找不到具有简单实现的单个示例!
解决方案
推荐阅读
- java - 基于角色/域组 Active Directory 的 Java Spring 访问
- arduino - 步进电机旋转不正确/不精确
- python-3.x - Python3:从套接字读取行时由对等方重置连接
- maven - 无法访问詹金斯工作区内的目录
- azure-devops - 当单元测试项目引用函数项目时,Azure 函数构建管道失败
- javascript - 在 Highcharts 的国家图表中使用 MapBubble
- r - 是否可以获得较低精度的路径长度?
- java - Kafka、Quarkus 和 Avro 在同一主题中的几种事件类型
- laravel-7 - 用户首次在 Laravel 7 中注册后如何重定向到动态路由
- jmeter - 我们可以停止 JMeter 负载测试自动停止吗