Comments (3)
Looks like it's due to some inconsistent error-handling around here: https://github.com/blinkmobile/hapi-oauth2orize/blob/master/index.js#L81-L98 . Your code generated an error which propagated down into a duplicate call to reply()
. This area of the code clearly needs a little bit of love :)
from hapi-oauth2orize.
Yes, the error inconsistently handled is that I was missing ?response_type= in the call.
Now I'm getting the same "reply called twice" because of a simple error of "cannot read property find of undefined", I suppose I need to create my own models now for clients, tokens, etc... instead of using the example code :)
Do you have any suggestion how to fix this error? Any related documentation or approach?
Usually I understand I cannot reply twice inside a function so I separate the two reply calls by and if else, but here the two reply calls are being made from different functions (inside and callback of oauth.authorize()).
My approach would be modifying the callback of authorize(request, reply, callback(req, res)) so it passes a variable called error with req and es and then we can if/else the two different replies with error or view.
Comments welcome!
from hapi-oauth2orize.
I have improved the code a little bit with this in my code (modifying the example code from README and commenting a line in index.js (169))
Comment this line, so we can see the actual error message:
https://github.com/blinkmobile/hapi-oauth2orize/blob/master/index.js#L169
Modify the oauth.authorize() callback like this, adding if(!request.response.isBoom)
authorize: function (request, reply) {
oauth.authorize(request, reply, function (req, res) {
if(!request.response.isBoom) {
reply.view('oauth', {transactionID: req.app.transactionID});
}
}, function (clientID, redirect, done) {
server.helpers.find('client', clientID, function (docs) {
done(null, docs[0], docs[0].redirect_uri);
});
});
},
So far working for me... but I'm showing some internal errors in the API output haha.
Maybe you can just not comment the line 169 so we "hide" the error from api users, but we still need a way to throw the error with the stack trace in console then.
from hapi-oauth2orize.
Related Issues (11)
- Add some documentation HOT 2
- different signatures in oauth.authorize HOT 2
- Error: Invalid plugin options {} HOT 13
- Hapi 12+ and yar bug fix HOT 5
- Help needed regarding implementation of resource owner password grant.
- oauth2orize is not working with hapijs HOT 1
- Hapi 17 HOT 1
- Hapi 8 and updated docs HOT 8
- Upgrade to hapi8 HOT 1
- Update docs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hapi-oauth2orize.