rahul
rahul

Reputation: 9

window azure authentication in java

window azure authentication in 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

Upvotes: 0

Views: 857

Answers (1)

Sandrino Di Mattia
Sandrino Di Mattia

Reputation: 24895

I answered a similar question a while back and this code actually works: Bing Search API Azure Marketplace Authentication in Java

The first issue I'm seeing is that you are calling Base64.encode, this should actually be: Base64.encodeBase64. And could you also try changing basic to Basic (in the setRequestProperty call)?

These changes together with a correct account key should solve the issue.

Upvotes: 1

Related Questions