Azure-Samples / active-directory-node-webapi

A NodeJS web API that is secured using Azure AD and OAuth 2.0 access tokens.
105 stars 64 forks source link

Error from Azure #8

Closed Petah closed 9 years ago

Petah commented 9 years ago

When running this and going to /task it just bounces me back with an error:

error: "invalid_request",
error_description: "AADSTS90014: The request body must contain the following parameter: 'response_type'. Trace ID: ******************* Correlation ID: ******************* Timestamp: 2015-03-17 20:55:34Z"

Even though the URL clearly has a response_type in it:

https://login.windows.net/***************/oauth2/authorize?api-version=1.0?response_type=code&redirect_uri=**************&client_id=***

brandwe commented 9 years ago

Did you ever get this to work? I can't reproduce it on this side.

tuxtina commented 9 years ago

Azure Portal ("View Endpoints") displays the OAuth2 Authorize URL as https://login.windows.net/***************/oauth2/authorize?api-version=1.0. When this URL is set for auth_endpoint in token.js, Passport will append all of its parameters starting with another question mark, effectively sticking all parameters into the api-version parameter.

I tried removing the api-version parameter. This results in TokenError: AADSTS50001: Resource identifier is not provided.. Just in case there is actually more than one API version, I also tried with a correct URL containing the api-version parameter (by modifying passport-oauth's strategy.js), but that also results in that same error.

To fix the missing resource identifier, I tried adding a resource parameter (set to 00000002-0000-0000-c000-000000000000, similar to what I've seen in the Azure AD Node.js sample code). This does seem to result in a token, but the sample code then fails with ReferenceError: User is not defined at OAuth2Strategy._verify. I believe this has already been reported as a bug here.

brandwe commented 9 years ago

Can you try this again? We've made many changes since April.