简体   繁体   English

Java中的窗口天蓝色身份验证

[英]window azure authentication in java

window azure authentication in java... Java中的窗口天蓝色身份验证...

String bingUrl = "https://api.datamarket.azure.com/Bing/Search/Web?Query='multiple'&$top=4&$skip=1&$format=json";
String accountKey = "HEPgn2ahb407EMW/j5TXKs5umkO6VDlb8anWMq+O2=";
byte[] accountKeyBytes = Base64.encode((accountKey + ":" + accountKey).getBytes());
String accountKeyEnc = new String(accountKeyBytes);
URL urlb = new URL(bingUrl);
URLConnection urlConnection =urlb.openConnection();
urlConnection.setRequestProperty("Authorization","basic " + accountKeyEnc);

but this is not working...here account key is not actual 但这不起作用...这里的帐户密钥不实际

I answered a similar question a while back and this code actually works: Bing Search API Azure Marketplace Authentication in Java 不久前,我回答了一个类似的问题,此代码实际上有效: Java中的Bing Search API Azure Marketplace身份验证

The first issue I'm seeing is that you are calling Base64.encode , this should actually be: Base64.encodeBase64 . 我看到的第一个问题是您正在调用Base64.encode ,它实际上应该是: Base64.encodeBase64 And could you also try changing basic to Basic (in the setRequestProperty call)? 并且您还可以尝试将basic更改为Basic (在setRequestProperty调用中)吗?

These changes together with a correct account key should solve the issue. 这些更改以及正确的帐户密钥应可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM