【问题标题】:nodejs -> OAuth2 Azure AD -> Error AADSTS50001nodejs -> OAuth2 Azure AD -> 错误 AADSTS50001
【发布时间】:2016-11-01 20:11:50
【问题描述】:

我希望允许我的用户使用他们的 Office 365 帐户访问我的 WebApp,就像我已经使用 Twitter、Facebook 和 google 所做的那样。 我已经在 Azure AD 中创建了一个 WebApp。

我正在使用 nodejs、passportjs 和 passport-azure-oauth2 策略。

在 Azure AD 中,Web 应用程序是多租户的,登录 URL 是“https://nudniq.com

APP ID URI:“https:\nudniq.com” 回复网址:“https:\nudniq.comauth\microsoft\callback” 访问应用程序需要用户分配:否

注意:我在此处发布的 URL 中使用反斜杠而不是斜杠,因为 stackoverflow 只允许我编写不超过两个链接。

我要求的唯一许可是:

Read all users' basic profiles

我正在用这个价值观制定我的策略:

clientID: '<client_id>',
clientSecret: '<client_secret_key>',
callbackURL: 'https://nudniq.com/auth/microsoft/callback'

但我收到以下错误:

TokenError: AADSTS50001: Resource identifier is not provided. 
Trace ID: 95f88f5a-95b9-4d3a-86fe-19ae0bbfcc76 
Correlation ID: b056150c-debd-469d-963b-ea362ca93884 
Timestamp: 2016-06-29 01:38:39Z
   at AzureOAuth2.OAuth2Strategy.parseErrorResponse (/home/ec2-user/test2/fastpass/node_modules/passport-oauth2/lib/strategy.js:298:12)
   at AzureOAuth2.OAuth2Strategy._createOAuthError (/home/ec2-user/test2/fastpass/node_modules/passport-oauth2/lib/strategy.js:345:16)
   at /home/ec2-user/test2/fastpass/node_modules/passport-oauth2/lib/strategy.js:171:43
   at /home/ec2-user/test2/fastpass/node_modules/oauth/lib/oauth2.js:177:18
   at passBackControl (/home/ec2-user/test2/fastpass/node_modules/oauth/lib/oauth2.js:123:9)
   at IncomingMessage.<anonymous> (/home/ec2-user/test2/fastpass/node_modules/oauth/lib/oauth2.js:143:7)
   at IncomingMessage.emit (events.js:129:20)
   at _stream_readable.js:908:16
   at process._tickDomainCallback (node.js:381:11)

请帮帮我,我不知道我做错了什么。

【问题讨论】:

    标签: node.js azure passport.js oauth2


    【解决方案1】:

    如果你使用AzureOAuthStrategy策略,当你出现这个问题时,说明你错过了配置resource参数。

    根据 GitHub 存储库中的代码示例:

    this.passport.use("provider", new AzureOAuth2Strategy({
      clientID: config.clientID,
      clientSecret: config.clientSecret,
      callbackURL: config.callbackUri,
      resource: config.resource,
      tenant: config.tenant,
      prompt: 'login',
      state: false
    }
    

    我们需要配置这个resource参数。
    由于您是Office 365 来验证您的用户,请尝试将resource 设置为https://graph.microsoft.com

    另外,请重新生成您的 AAD 应用程序的密钥,并将其保存在您的应用程序中,不要将其公开。

    如有任何更新,请随时告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-03
      • 2018-05-02
      • 2021-02-01
      • 2021-12-13
      • 1970-01-01
      • 2020-10-09
      • 2023-04-08
      • 2020-05-10
      相关资源
      最近更新 更多