我跟随博客开发了一个无需用户登录即可读取用户邮件的应用程序:http : //blogs.msdn.com/b/exchangedev/archive/2015/01/21/building-demon-or-service- apps与办公室365邮件日历和联系人apis-oauth2-client-credential-flow.aspx?CommentPosted = true#commentmessage
我获得了ID令牌并获得了租户ID。当我尝试获取访问令牌时,它将引发错误:
{"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库。我正在使用围棋语言。
我使用HMAC base64对字符串进行了签名,然后对其进行了URL编码,然后按照上述文章中的说明将其附加到字符串上。这是我的客户主张
eyJhbGciOiJSUzI1NiIsIng1dCI6IjZlLzEra01scHhuTHArZFJ4d1BqS21EdmZCQT0ifQ.eyJhdWQiOiJodHRwczovL2xvZ2luLndpbmRvd3MubmV0L2ZmNjQxNTFmLTIwM2EtNGM0MC1hZDcxLTExOTE2YjY2Yzg3My9vYXV0aDIvdG9rZW4iLCJleHAiOjE0MjU3Mzc2MDEsImlzcyI6Ijk3MjhiOGFiLTVhOGUtNGM0OC05YTZkLTZmMzFjMWYyZTdkYyIsImp0aSI6IjMyMDZiYWI5LTVmYmUtNDA3ZS02OWY2LTJlNGRjNDQ3NzQxYSIsIm5iZiI6MTQyNTc0MjYwMSwic3ViIjoiOTcyOGI4YWItNWE4ZS00YzQ4LTlhNmQtNmYzMWMxZjJlN2RjIn0.pG4okCzcgXZbS067U9BkGWid6Z6ExU7pbPYOlm2mSAg
我要去哪里错了?
该错误表明您的签名有问题。与工作的相比,它要短得多。确保使用RSA SHA-256哈希对字符串进行签名。使用HMAC可能是造成此问题的原因。