@julian I have ditched Heroku. Deployed the app on cloud9 and it is working fine. I then try to use my plugin and I still get the same error. Here is the error on nodebb

at OAuth2Strategy._createOAuthError (/home/ubuntu/workspace/node_modules/nodebb-plugin-sso-oauth/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:379:17)
at /home/ubuntu/workspace/node_modules/nodebb-plugin-sso-oauth/node_modules/passport-oauth/node_modules/passport-oauth2/lib/strategy.js:166:45
at /home/ubuntu/workspace/node_modules/nodebb-plugin-sso-oauth/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:191:18
at passBackControl (/home/ubuntu/workspace/node_modules/nodebb-plugin-sso-oauth/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:132:9)
at IncomingMessage.<anonymous> (/home/ubuntu/workspace/node_modules/nodebb-plugin-sso-oauth/node_modules/passport-oauth/node_modules/passport-oauth2/node_modules/oauth/lib/oauth2.js:157:7)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:921:12)
at nextTickCallbackWith2Args (node.js:442:9)

I am really frustrated I have searched the internet for help the only help I get is with respect to a possible typo or firewall. My authorization codes are being created in my database it is just at the exchange point that the failure happens.

It is a pretty awful user experience to log into the forum after logging into my web app.

Would definitely be using nodebb for a stand-alone forum but this is me giving up after a 4 day battle. I might as well have built a very simple forum for my website in those 4 days. Ugh!!!

@julian I am on nodebb version 1.4.3 not sure if that is develop branch as I am not so good with git. Yes it is not related. I just wanted to isolate the cause of my failure to log in programmatically by hosting on Heroku and trying it from there.

and then modified web.js line 34 inside the install folder to port = process.env.PORT || port; Otherwise, it would load at port 4567 which was always failing. I think I also added process.env.PORT to line 145 in loader.js but I don't think that changed anything much. It only started nodebb when I modified web.js

@julian I have been patiently waiting for a response. However, I tried to install nodebb on heroku. It was a painful process but I came to my wits ends when I got to the launch page. It says congratulations your nodebb has been setup but won't get past that page. It returns a 404 error whilst making a get request for /admin.

@julian this is to hoping you'd help me complete this hurdle. As shown in the picture, I am getting the code but I don't know what to make of the error I am getting. I tried to deploy nodebb on Heroku since the error could possibly be because I am using local host but I ran into other issues with nodebb crashing on Heroku and that is like opening two battle fronts needlessly. I think I would proceed one step at a time.

Like I said, when I run my authorizationUrl on my browser, it gives an error 401 with the grant code. The resource I saw online said this was perfectly normal. If I copy the code and make a post request for my token on PostMan, it exchanges the code for a token and then I complete by posting to my user endpoint to get user details so I think the whole process is working and possibly I am just one correction away from saving you the stress of having to answer someone else trying to do this on node js because as I mentioned earlier, I will write down what worked for me and the resources I used.

It still has to do with the call back uri. I really don't know what to do next since the url points to nodebb and not to me so I can't create an endpoint or something.

I am not so sure but I have a little idea of what my problem is but even at that I don't know how to solve it. I traced the error logs to an oauth2 file and it requests that the page returns between 200 and 299 status code but mine is returning 500. How can I return 200 when the link is not on my site. I am really getting confused.

@julian I see. I thought all the user needed to do was to log in on my site and when he clicks on the forum link on my website there would be a handshake between my website and nodebb and then sign him on. I didn´t know he had to click on the log in/register link on nodebb.

I still have some questions though:

So I have to make a page and endpoint for /auth/example right? I believe oauth2orize would be responsible for the redirection.

I read your code and you always append callback if I am to make an endpoint or page it would never be executed because I would have /auth/example whilst the plugin would contain /auth/example/callback.

I think the process is a bit clearer to me right now. I have been programming javascript and node for about 3 months which is not much admittedly but this is hands down the most complicated thing I have come across as I don't have a full grasp of the whole process and it has very little to do with your programming skills imo and more to do with how much you understand libraries and all.

any chance @julian or someone else who has done this would help push me the right direction.

I think I am doing everything right but there is no message whatsoever on nodebb's log to see if I am mistaken.

PS: I just noticed something that could be causing problems for me. What is the name required supposed to do. I noticed it is being used in strategies.push from my understanding of how this works: nodebb makes a call to my authorization end point and I check if the client is correct and grant it an access code, it then visits my token end point and exchanges this access code for a token. I take it to the user end point and hands it my users credentials to log in. I think I am wrong since it is not working.