oktadev / okta-express-graphql-example

Apache License 2.0
16 stars 9 forks source link

Shipped example does not work - problem with OIDC middleware #3

Open johnbcable opened 6 years ago

johnbcable commented 6 years ago

The messages from npm install on screen were as follows:

Johns-iMac:okta-express-graphql-example-master a03pl$ npm install

fsevents@1.2.4 install /Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/fsevents node install

[fsevents] Success: "/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed Pass --update-binary to reinstall or --build-from-source to recompile

nodemon@1.18.4 postinstall /Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/nodemon node bin/postinstall || exit 0

npm WARN graphql-express@1.0.0 No repository field. npm WARN graphql-express@1.0.0 license should be a valid SPDX license expression

added 716 packages from 485 contributors and audited 3214 packages in 22.179s found 1 low severity vulnerability run npm audit fix to fix them, or npm audit for details Johns-iMac:okta-express-graphql-example-master a03pl$

Messages from npm start thereafter were:

Johns-iMac:okta-express-graphql-example-master a03pl$ npm start

graphql-express@1.0.0 start /Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master nodemon .

[nodemon] 1.18.4 [nodemon] to restart at any time, enter rs [nodemon] watching: . [nodemon] starting node . Running a GraphQL API server at localhost:4000/graphql (node:43310) UnhandledPromiseRejectionWarning: HTTPError: Response code 405 (Method Not Allowed) at stream.catch.then.data (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/openid-client/node_modules/got/index.js:386:13) at at process._tickCallback (internal/process/next_tick.js:188:7) (node:43310) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:43310) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

and then visiting http://localhost:4000/access-token give the following in-browser failure message:

Error: Unknown authentication strategy "oidc" at attempt (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/passport/lib/middleware/authenticate.js:173:37) at authenticate (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/passport/lib/middleware/authenticate.js:349:7) at /Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/@okta/oidc-middleware/src/connectUtil.js:79:28 at Layer.handle [as handle_request] (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/express/lib/router/index.js:317:13) at /Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/express/lib/router/index.js:335:12) at next (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/express/lib/router/index.js:275:10) at urlencodedParser (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/body-parser/lib/types/urlencoded.js:91:7) at Layer.handle [as handle_request] (/Users/a03pl/Sites/Tutorials/GraphQL/okta-express-graphql-example-master/node_modules/express/lib/router/layer.js:95:5)

I think this may relate to the @okta/oidc-sdk-nodejs installation as this appears not to exist (using npm search)

Can this be corrected please so the example can actually run?

I do have an OKTA developer account and the .env file has the correct credentials in it. I am running on MacOS Sierra on an iMac.

mraible commented 6 years ago

Could this be related to https://github.com/oktadeveloper/okta-express-graphql-example/issues/2?

johnbcable commented 6 years ago

Don’t think so. I’ve done what it suggests there but still get the same in-browser error screen as originally forwarded. My package.json file for this example, modified as suggested by that blog entry, is as follows:

{ "name": "graphql-express", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "standard", "start": "nodemon ." }, "keywords": [], "author": "", "license": "Apache 2.0", "dependencies": { "@okta/jwt-verifier": "0.0.12", "@okta/oidc-middleware": "^1.0.0", "@okta/okta-sdk-nodejs": "^1.2.0", "cors": "^2.8.4", "dotenv": "^6.0.0", "express": "^4.16.3", "express-graphql": "^0.6.12", "express-session": "^1.15.6", "graphql": "^14.0.2", "graphql-tag": "^2.9.2", "standard": "^12.0.1", "uuid": "^3.3.2" }, "devDependencies": { "nodemon": "^1.18.4" } }

and then node_modules was removed and application nom install ‘ed from scratch using this package.json

On 14 Oct 2018, at 15:34, Matt Raible notifications@github.com wrote:

Could this be related to #2 https://github.com/oktadeveloper/okta-express-graphql-example/issues/2?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/oktadeveloper/okta-express-graphql-example/issues/3#issuecomment-429631344, or mute the thread https://github.com/notifications/unsubscribe-auth/ACfE7OF3smLX43U-Pj-BcevI-3G5f0jBks5uk0tdgaJpZM4XbGUW.

redbmk commented 6 years ago

@johnbcable did you follow along with the blog, or did you just clone this repo? What if you run npm test - do you get any errors? Also what version of node and npm are you using (node --version, and npm --version)?

I'm having a hard time recreating the same errors you're getting.