Bug in Authorization Flow Tutorial - NodeJS

Hello Community

I am trying to get the NodeJS version of the sky-api-auth-tutorial running on my local machine. I am unable to start the app via “npm start” due to an error I am receiving in the auth.js file.

routes is an object in this file, I have attached a photo of the stacktrace for reference.

All of the dependencies have been installed successfully.

Would this be due to a version mismatch in Node?

I do have programming experience but am new to Node and Express. I am hoping it's something simple!

7738e6dde5c29f66eb3d01a5974e0eb0-huge-sc

Comments

  • Michael Tims
    Michael Tims Blackbaud Employee
    Sixth Anniversary Kudos 2 Name Dropper Participant

    Hi @Daniel Fierro - I'm going to try to reproduce on my end.
    Just a couple questions:
    - What version of nodejs are you running?
    - Did you happen to run “npm install” before running “npm start”? If so, do you see any errors in the console during the “npm install” process?

    Thanks!

  • Michael Tims
    Michael Tims Blackbaud Employee
    Sixth Anniversary Kudos 2 Name Dropper Participant

    @Daniel Fierro I'm able to run the application via “npm start” without any errors.

    I am using nodejs v14.17.0

  • Hey Michael,

    I am using node version 15.10.0.

    The issue seemed to originate from an incompatibility with the simple-oauth2 package which is at 4.2.0

    I got the app running by altering the require statement to conform with their docs

    eg

    const { ClientCredentials, ResourceOwnerPassword, AuthorizationCode } = require('simple-oauth2');

    The apps runs now but I am trying to quash another bug occurring when submitting the authorize app form

  • Michael Tims
    Michael Tims Blackbaud Employee
    Sixth Anniversary Kudos 2 Name Dropper Participant

    Hey @Daniel Fierro ,

    The sample app does depend on quite a few very outdated versions of some packages. We can work on getting the sample working with later versions.

    But those older versions shouldn't prevent you from running the sample app as is. I see you mentioned that simple-oauth2 v4.2.0 is being used. I wouldn't have expected npm install to have pulled in the latest major version since package.json depends on ^0.2.1. Did you happen to manually update the simple-oauth2 package? That could be the problem.

    Maybe you could try to delete the node_modules folder and package-lock.json file, and then try running npm install again?

  • Hi Michael!

    You're absolutely right. The warning message node produced when installing the dependencies pretty much recommended against using the older version so I did do the npm audit --force initially . I did manage to get the app working with the older version of simple-oauth2 though! My goal is to get both versions working. If I manage to get the app running fully with the newer simple-oauth2 pkg, I can let you know if you'd like?

  • Michael Tims
    Michael Tims Blackbaud Employee
    Sixth Anniversary Kudos 2 Name Dropper Participant

    Hi @Daniel Fierro , glad you have it working! Sure, if you do get it working with newer packages it would be nice for us to know. We do want to try and get that sample/tutorial code up to date.

    Thanks!

Categories