0

我有一个 React Native Client,它从 Azure Active Directory 获取 access_token,然后在标头的 Node.js API 中传递令牌。

在 Node.js API 中,该令牌将被验证......

我有一个名为 azure-ad-jwt 的 NPM 模块,

我尝试使用这段代码来验证令牌。

const aad = require('azure-ad-jwt');
const token = '<<<<My Token>>>>';

aad.verify(token, { audience: 'https://graph.microsoft.com' }, (err, result) => {
  if (result) { console.log('Valid Token'); }
  else if (err) { console.log(err); }
});

我不知道我是否遗漏了任何东西或我的配置有问题。

我收到此错误:JsonWebTokenError: invalid signature

尽管我的令牌已正确解码所有信息。

我不知道为什么它仍然会抛出这个错误。

如果有人能纠正这个错误并帮助我找到解决方案,那就太好了。

伙计们,这是令牌

eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFDRWZleFh4amFtUWIzT2VHUTRHdWd2RlhUMlRPNXhaR2s0MEZydnNSYnV6TDlzajdnWUhXNVFuX0pDVHZGRjlzMTRNUndOMWxJSlNGQzVtVm9tMzh6MmxzakpaTnVlcHNLOTc0VEQwZEtneWlBQSIsImFsZyI6IlJTMjU2IiwieDV0IjoibmJDd1cxMXczWGtCLXhVYVh3S1JTTGpNSEdRIiwia2lkIjoibmJDd1cxMXczWGtCLXhVYVh3S1JTTGpNSEdRIn0.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9mOTc1NmY0Mi0yN2MyLTRiNWQtOWQyNC01YTc2MDRmNzBlZjcvIiwiaWF0IjoxNTQ3MDI4NjIyLCJuYmYiOjE1NDcwMjg2MjIsImV4cCI6MTU0NzAzMjUyMiwiYWNjdCI6MSwiYWNyIjoiMSIsImFpbyI6IkFUUUF5LzhLQUFBQVJSNUwwZnZKc1RTV3F0ZSI6IlVubml0aS1TZXJ2ZXIiLCJhcHBpZCI6ImIzZTllNGE1LTEzMzgtNDExMi1hNTFkLThlODNiY2Y0ZGQ4NSIsImFwcGlkYWNyIjoiMS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sLkFsbCBTdWJzY3JpcHRpb24uUmVhZC5BbGwgVXNlci5FeHBvcnQuQWxsIFVzZXIuSW52aXRlLkFsbCBVc2VyLlJlYWQgVXNlci5SZWFkLkFsbCBVc2VyLlJlYWRXcml0ZS5BbGwiLCJzdWIiOiJGN1g2eGVaYlBrYTJzT2xxcU5qTzNLWHBTeWdpWHc3UUY1MHMtTVVNOWJRIiwidGlkIjoiZjk3NTZmNDItMjdjMi00YjVkLTlkMjQtNWE3NjA0ZjcwZWY3IiwidW5pcXVlX25hbWUiOiJzdXNoYW50a0BwcmR4bi5jb20iLCJ1dGkiOiJBXzIxblNGSzhFR2ZRODlnYzJZWUFBIiwidmVyIjoiMS4wIiwieG1zX3RjZHQiOjE1MzM2ODM3MzN9.OreAmua43bv6SDHOoYFnTQl97K4Zoz8PJjlPDGkKoJvUBZgy5HzfPGMutUGMpYfKRkdG_01aUuwG-DJGiFwJzMvpPVyMt3YVldd7Q7mZuP3k9_WVnp32XU7v47HijGxSrdiGVAq6qaZLEqAUs23CupseVsJ6NFTpTuxfDoCEgs8uCqYGlz5-oZvbkyxyQvrP7HBLxDKT0dL-SOLisVERyaJbW9gdQqEhzv9KGbhov_Eq0FIHkjLpJehU7cRF9tXGJF8ISRP71WrYkLwVJMjhnL4YqsPeWfnR9cnOmeSaFKe2OYFC97AMNpMFNV8WAsPpqJHb9HuLKHVmLTLqZPg3Fw

谢谢!

4

1 回答 1

1

在 Node.js API 中,该令牌将被验证

您想验证 Node.js API 的令牌,但您的受众是https://graph.microsoft.com,您应该请求 Node.js API 的令牌,而不是 microsfot 图 API。

于 2019-01-10T07:04:16.783 回答