mulesoft-labs / js-client-oauth2

A JavaScript implementation of an oauth2 client, for inclusion in the JavaScript client generator for APIs described with RAML.
Other
539 stars 145 forks source link

Unhandled promise rejection. Error: Missing client_id query parameter #77

Open WojtekBator opened 6 years ago

WojtekBator commented 6 years ago

Hi!

I'm trying to implement authorization code grant flow using Your library. I'm following the instructions from readme. Hovewer, in a callback handler when I want to receive a token, line: let data = await this.auth.code.getToken(req.originalUrl); I get the response of: Unhandled promise rejection. Error: Missing client_id query parameter.

This comes from getAuthError from inside. My req.originalUrl is like this: /connect/provider/callback?code=ecc61ca2. The provider needs to get client id and secret and all the stuff in the url which was passed as a auth constructor parameter at the beginning. Digging a bit into the code, this stuff should be into options object.

Structure of config object passed to auth:

{
        clientId: 'id',
        clientSecret: 'secret',
        accessTokenUri: 'their correct token uri'',
        authorizationUri: 'their correct auth uri',
        redirectUri: 'http://site.com/connect/provider/callback',
}

Did You guys encounter this and have any idea of how to proceed? I have newest lib version

Airfooox commented 5 years ago

Same problem here. Same setup and doesn't work like it should.

Any ideas?

dcowsill commented 5 years ago

I was having a similar issue. I was using Node 8.10.0 (for AWS lambda compat) and switching over to 10.16.3 (LTS) resolved it for me.

Hope this helps!