Skip to content
New issue

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

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

Already on GitHub? # to your account

Random failure of google oauth callback #5

Closed
sanjacob opened this issue Sep 21, 2023 · 2 comments
Closed

Random failure of google oauth callback #5

sanjacob opened this issue Sep 21, 2023 · 2 comments
Assignees

Comments

@sanjacob
Copy link

Expected Behavior

Google OpenID connect provider redirecting successfully

Current Behavior

Request hangs and ultimately fails:

[Nest] 14807  - 21/09/2023, 12:48:16   ERROR [ExceptionsHandler] Failed to obtain access token
InternalOAuthError: Failed to obtain access token
    at /prj/node_modules/@govtechsg/passport-openidconnect/lib/strategy.js:283:29
    at /prj/node_modules/oauth/lib/oauth2.js:191:18
    at ClientRequest.<anonymous> (/prj/node_modules/oauth/lib/oauth2.js:162:5)
    at ClientRequest.emit (node:events:513:28)
    at TLSSocket.socketErrorListener (node:_http_client:502:9)
    at TLSSocket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Failure Information (for bugs)

This happens only sometimes, completely arbitrarily.

Steps to Reproduce

I am using Nest.js and @nestjs/passport, with this package. I set up an auth strategy with Google.

Context

Here is my package.json

{
  "name": "",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "UNLICENSED",
  "scripts": {
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@govtechsg/passport-openidconnect": "^1.0.1",
    "@nestjs/common": "^10.0.0",
    "@nestjs/config": "^3.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/jwt": "^10.1.1",
    "@nestjs/passport": "^10.0.1",
    "@nestjs/platform-express": "^10.0.0",
    "@nestjs/swagger": "^7.1.8",
    "@nestjs/typeorm": "^10.0.0",
    "@types/nanoid": "^3.0.0",
    "class-transformer": "^0.5.1",
    "class-validator": "^0.14.0",
    "express-session": "^1.17.3",
    "mysql2": "^3.6.0",
    "nanoid": "^3.3.6",
    "passport": "^0.6.0",
    "passport-jwt": "^4.0.1",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^7.8.1",
    "typeorm": "^0.3.17"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@swc/cli": "^0.1.62",
    "@swc/core": "^1.3.82",
    "@types/express": "^4.17.17",
    "@types/express-session": "^1.17.7",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/passport-strategy": "^0.2.35",
    "@types/supertest": "^2.0.12",
    "@typescript-eslint/eslint-plugin": "^6.0.0",
    "@typescript-eslint/parser": "^6.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^6.3.3",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  }
}

Failure Logs

None

@sanjacob
Copy link
Author

sanjacob commented Sep 21, 2023

Seems to be related to passport/todos-express-openidconnect#1

@seng-siong
Copy link

Seem related to jaredhanson/passport-google-oauth2#87.

I've made a new release v1.0.2 that bumps the oauth package to v0.10.0 that should fix the issue. Give it a try and let me know how it goes.

Thank you .
seng-siong

@seng-siong seng-siong self-assigned this Oct 4, 2023
@sanjacob sanjacob closed this as completed Oct 4, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants