无法检索Office 365的应用程序唯一令牌 [英] Could not retrieve app only tokens for office 365

查看:146
本文介绍了无法检索Office 365的应用程序唯一令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着博客开发了一个应用程序,它可以读取用户的邮件,而无需登录他们: http:/ /blogs.msdn.com/b/exchangedev/archive/2015/01/21/building-demon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential -flow.aspx?CommentPosted = true#commentmessage

I followed the blog to develop an application that reads mails of users without having them signed in: http://blogs.msdn.com/b/exchangedev/archive/2015/01/21/building-demon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow.aspx?CommentPosted=true#commentmessage

我得到了id令牌并获得了租户Id。当我尝试获取访问令牌时,它会引发错误:

I got the id token and got the tenant Id. When i try to get the access token it throws an error:

{"error":"invalid_client","error_description":"AADSTS70002: Error validating cre
dentials. AADSTS50012: Client assertion contains an invalid signature.\r\nTrace
ID: 9646a93b-0094-4736-8d21-aed08f04b06e\r\nCorrelation ID: 8dd562af-556d-4d90-9
f71-a60f5a232215\r\nTimestamp: 2015-03-03 10:47:25Z","error_codes":[70002,50012]
,"timestamp":"2015-03-03 10:47:25Z","trace_id":"9646a93b-0094-4736-8d21-aed08f04
b06e","correlation_id":"8dd562af-556d-4d90-9f71-a60f5a232215","submit_url":null,
"context":null}

但是我创建了证书按照说明。我没有使用ADAL库。我正在使用go语言。所以我遵循堆栈溢出链接中的步骤: Office 365 Rest API - 守护程序周身份验证

But I created the certificate as per the instructions. I am not using ADAL library. I am using go language. So i followed the steps in a stack overflow link: Office 365 Rest API - Daemon week authentication

我使用HMAC base64对字符串进行了编码并对其进行了编码,然后将其附加到字符串,如上面的文章中所述。这是我的客户断言

I signed the string using HMAC base64 encoded it and URL encoded it and then appended to the string as explained in the above post. This is my client assertion

eyJhbGciOiJSUzI1NiIsIng1dCI6IjZlLzEra01scHhuTHArZFJ4d1BqS21EdmZCQT0ifQ.eyJhdWQiOiJodHRwczovL2xvZ2luLndpbmRvd3MubmV0L2ZmNjQxNTFmLTIwM2EtNGM0MC1hZDcxLTExOTE2YjY2Yzg3My9vYXV0aDIvdG9rZW4iLCJleHAiOjE0MjU3Mzc2MDEsImlzcyI6Ijk3MjhiOGFiLTVhOGUtNGM0OC05YTZkLTZmMzFjMWYyZTdkYyIsImp0aSI6IjMyMDZiYWI5LTVmYmUtNDA3ZS02OWY2LTJlNGRjNDQ3NzQxYSIsIm5iZiI6MTQyNTc0MjYwMSwic3ViIjoiOTcyOGI4YWItNWE4ZS00YzQ4LTlhNmQtNmYzMWMxZjJlN2RjIn0.pG4okCzcgXZbS067U9BkGWid6Z6ExU7pbPYOlm2mSAg

我在哪里出错?

Where am I going wrong?

推荐答案

错误表明存在问题与您的签名。与工作相比,它更短。请确保您使用RSA SHA-256哈希签名字符串。使用HMAC可能会导致此问题。

The error indicates there's a problem with your signature. Comparing with a working one, it is way shorter. Be sure you're signing the string with an RSA SHA-256 hash. Using HMAC is probably causing the issue.

这篇关于无法检索Office 365的应用程序唯一令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆