Skip to content

err.toString returned from getToken will throw illegal access exception #382

Closed

Description

@henryliu-git

I accidentally set the wrong redirect url and when I call oauth2Client.getToken, I expect I can get some related error message like redirect_uri_mismatch.

But instead I got illegal access exception when I do console.log(err).

b6fcdf3

Maybe it is because setting err.type = body.error while body.error_description is empty in this case?

Activity

  1. ahuntcirruspath commented on Mar 11, 2015

    @ahuntcirruspath

    +1 I have a similar scenario and found that it's due to the body.error_description issue. For me, "illegal access" was actually the error from the Error object and not the api. It can be found in "google-auth-library/lib/transporters.js" file near line 78.

    When I change body.error_description to body.error, I got the appropriate api error: "invalid grant".

  2. ashaffer commented on Mar 27, 2015

    @ashaffer

    This is definitely a consequence of .type being set on an Error instance. I am having this issue as well. Really needs to be fixed, it's extremely difficult to debug, as node doesn't offer a stack trace for it.

    Reference for the .type issue in node: http://www.karadzhov.com/2014/06/nodejs-and-illegal-access-error.html

  3. JustinBeckwith commented on Mar 4, 2018

    @JustinBeckwith
    Contributor

    This appears to be fixed in the latest version. I now get an error like this:

    $ node samples/drive/list.js 
    Error getting oAuth tokens: Error: invalid_grant
    (node:83866) UnhandledPromiseRejectionWarning: Error: invalid_grant
        at createError (/Users/beckwith/Code/google-api-nodejs-client/node_modules/axios/lib/core/createError.js:16:15)
        at settle (/Users/beckwith/Code/google-api-nodejs-client/node_modules/axios/lib/core/settle.js:18:12)
        at IncomingMessage.handleStreamEnd (/Users/beckwith/Code/google-api-nodejs-client/node_modules/axios/lib/adapters/http.js:201:11)
        at IncomingMessage.emit (events.js:165:20)
        at endReadableNT (_stream_readable.js:1101:12)
        at process._tickCallback (internal/process/next_tick.js:152:19)
    
    

    Let me know if you're still running into any problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions