Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
henryliu-git opened this issue Mar 5, 2015 · 3 comments
Closed
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@henryliu-git
Copy link

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?

@ahuntcirruspath
Copy link

+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".

@ashaffer
Copy link

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

@JustinBeckwith
Copy link
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
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

5 participants