goferito / node-bing-api

Node.js module for the Bing Search API (Cognitive Services)
MIT License
56 stars 28 forks source link

The authorization type you provided is not supported. Only Basic and OAuth are supported #23

Closed reyreaud-l closed 8 years ago

reyreaud-l commented 8 years ago

Hi, just started to use this package. However each request return this error:

The authorization type you provided is not supported. Only Basic and OAuth are supported

looking into the lib I think microsoft updated the header they require. I tested my key and it works in microsoft console at : https://dev.cognitive.microsoft.com/docs/services/56b43f72cf5ff8098cef380a/operations/56f02400dbe2d91900c68553/console

petrsimanek commented 8 years ago

I get also this error.

SharonStrats commented 8 years ago

me too....

neilhoff commented 8 years ago

It looks like this works with the Bing Search API from the Azue Datamarket: https://datamarket.azure.com/dataset/bing/search

I get the same error when I was using: https://www.microsoft.com/cognitive-services/en-us/bing-news-search-api

I am not sure what the difference is or why they have two versions.

SharonStrats commented 8 years ago

Thank you! I will try that.

On Friday, September 2, 2016, Neil Hoff notifications@github.com wrote:

It looks like this works with the Bing Search API from the Azue Datamarket: https://datamarket.azure.com/dataset/bing/search

I get the same error when I was using: https://www.microsoft.com/cognitive-services/en-us/bing-news-search-api

I am not sure what the difference is or why they have two versions.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/goferito/node-bing-api/issues/23#issuecomment-244227367, or mute the thread https://github.com/notifications/unsubscribe-auth/AI-fm0hV--uHarTITMfzwfzUk7Vk3FTDks5ql0xUgaJpZM4JKJz6 .

aschoenher commented 8 years ago

Hi everyone,

I found a way to fix the bug.

You have to edit the lib twice :

Firstly, we update the rootUri (from datamarkets to cognitive services)

 23     //Bing Search API URI
 24     rootUri: "https://api.cognitive.microsoft.com/bing/v5.0/",

Then we send the key in the header (instead of the auth param) :

101       headers: {
102           "User-Agent": opts.userAgent,
103           "Ocp-Apim-Subscription-Key": opts.accKey
104       },

Now, everything works for me 👍

reyreaud-l commented 8 years ago

Indeed looks like it's working now. Quite forgot about but thanks for the update!

goferito commented 8 years ago

Hi guys, I'm currently quite tight in time to fix this thing, but if someone could make a PR with the solution I will gladly accept it. Thanks, and sorry for my low attention here :confused:

aschoenher commented 8 years ago

I’ll need some time to clean up the mess I made 😄 In fact all requests need to be rebuilt partially (new params, old params deleted…)

But why not ?! If nobody else is up to the task, it could be a fun challenge 👍

ankur1163 commented 8 years ago

can someone post full code here? I am still confused how to implement @aschoenher solution