drgaeqdqiiyg14608 2015-03-03 12:38
浏览 48
已采纳

无法检索Office 365的仅应用程序令牌

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

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.
Trace
ID: 9646a93b-0094-4736-8d21-aed08f04b06e
Correlation ID: 8dd562af-556d-4d90-9
f71-a60f5a232215
Timestamp: 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}

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

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?

  • 写回答

1条回答 默认 最新

  • dsd119120 2015-03-03 15:44
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能