jaredhanson / passport-google-oauth

Google authentication strategies for Passport and Node.js.

Home Page:https://www.passportjs.org/packages/passport-google-oauth/?utm_source=github&utm_medium=referral&utm_campaign=passport-google-oauth&utm_content=about

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InternalOAuthError "message": "failed to fetch user profile"

jjchando opened this issue · comments

We've been using this module for a couple years now with no issues. All of a sudden over the past 24-48 hours without any code changes we've seen a huge amount of errors like these repeatedly.

/api/v2/login/google/return{
   "name": "InternalOAuthError",
   "message": "failed to fetch user profile",
   "oauthError": {
       "statusCode": 500,
       "data": "{\n \"error\": {\n  \"errors\": [\n   {\n    \"domain\": \"global\",\n    \"reason\": \"backendError\",\n    \"message\": \"Backend Error\"\n   }\n  ],\n  \"code\": 500,\n  \"message\": \"Backend Error\"\n }\n}\n"
   }
}

Also

/api/v2/login/google/return{
   "name": "InternalOAuthError",
   "message": "failed to obtain access token",
   "oauthError": {
       "statusCode": 400,
       "data": "{\n  \"error\" : \"invalid_grant\",\n  \"error_description\" : \"Code was already redeemed.\"\n}"
   }
}

Anyone have any ideas? Thanks.

I was getting a similar error:

InternalOAuthError: failed to fetch user profile
    at /Users/danvk/github/better-mobility/node_modules/passport-google-oauth2/lib/oauth2.js:92:28

I went to that file and console.log'd the err object. It spit this out:

{ statusCode: 403,
  data: '{\n "error": {\n  "errors": [\n   {\n    "domain": "usageLimits",\n    "reason": "accessNotConfigured",\n    "message": "Access Not Configured. The API (Google+ API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",\n    "extendedHelp": "https://console.developers.google.com"\n   }\n  ],\n  "code": 403,\n  "message": "Access Not Configured. The API (Google+ API) is not enabled for your project. Please use the Google Developers Console to update your configuration."\n }\n}\n' }

That's a much more helpful error message! Maybe try something similar?

passport-google-oauth should do a better job of surfacing this error.

got same error:

InternalOAuthError: Failed to fetch user profile (status: 500 data: {
 "error": {
  "code": 500,
  "message": null
 }
}
)
    at /var/www/node_modules/passport-google-oauth20/lib/strategy.js:99:19
    at passBackControl (/var/www/node_modules/oauth/lib/oauth2.js:132:9)
    at IncomingMessage.<anonymous> (/var/www/node_modules/oauth/lib/oauth2.js:157:7)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

package: passport-google-oauth@1.0.0