【发布时间】:2017-08-19 22:23:59
【问题描述】:
我正在尝试开发一个能够访问我的 Outlook.com 邮件的节点应用程序。
我正在尝试以一种不需要我输入凭据的方式来执行此操作,应用程序会知道它们(用户名和密码)。我不太担心将它们存储在我的应用程序的配置中。
我正在使用 simple-oauth2,但我不断收到错误消息。以下是尝试检索 Oauth 令牌的代码:
const credentials = {
client: {
id: this.appId,
secret: this.appSecret,
},
auth: {
tokenHost: "https://login.microsoftonline.com",
authorizePath: "common/oauth2/v2.0/authorize",
tokenPath: "common/oauth2/v2.0/token",
},
};
const oathClient = oauth2.create(credentials);
const tokenConfig = {
username: "zzz@outlook.com",
password: "xxxxx",
scope: "Mail.Read",
};
const result = await oathClient.ownerPassword.getToken(tokenConfig);
const token = oathClient.accessToken.create(result);
但是,当调用 get token 时,我得到以下响应:
"error": "invalid_grant",
"error_description": "AADSTS70000: The grant is not supported by this API version\r\nTrace ID: 91935472-5d7b-4210-9a56-341fbda12a00\r\nCorrelation ID: 6b075f4e-b649-493e-a87b-c74f0e427b47\r\nTimestamp: 2017-08-19 14:00:33Z",
"error_codes": [ 70000],
我已在 apps.dev.microsoft.com 中添加了该应用程序
为其添加了一个平台(Web API)。 在 Microsoft Grah 上添加了“Mail.Read”权限
我正在使用我在那里生成的 apikey 和秘密。
谷歌搜索看起来我发现的所有连接示例都是使用客户端证书。是否可以通过 API 凭据使用 API?
如果唯一的方法是使用证书,有没有一种方法可以使用 simple-oauth2?
【问题讨论】:
标签: node.js oauth-2.0 office365