Closed pabl-o-ce closed 8 years ago
Hi @pablocarreraest, sorry for the late reply, I was on holidays for a couple of weeks.
Answers: 1: You could use server cache to store tokens in server memory.
2: What library do you plan to use to create a jsonwebtoken, I can show you then?
3: Example: Just modify the validate function to use server cache instead of DB:
function validate (token, callback) {
// this would have been created when creating your server with:
// server.app.userCache = server.cache({ segment: 'userCache', expiresIn: 60 * 60 * 1000 });
server.app.userCache.get(token, (err, value, cached, log) => {
if (err || !value) {
return callback(null, false);
}
return callback(null, true, value);
})
}
great example thanks @johnbrett
no problem @pablocarreraest.
@johnbrett Hi I need your little help that, How can I send access token from postman
The easiest is probably append it to the url like ?access_token=123.
Make sure to enable query params tokens when registering the auth strategy!
On Sat, 17 Jun 2017, 22:36 Ishan, notifications@github.com wrote:
@johnbrett https://github.com/johnbrett Hi I need your little help that, How can I send access token from postman
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/johnbrett/Getting-Started-with-hapi.js/issues/8#issuecomment-309238719, or mute the thread https://github.com/notifications/unsubscribe-auth/AD1HQ_SyZMUaJHPDKlzcKj1CAeZaXlBeks5sFDjJgaJpZM4I2lao .
-- John Brett
Stay in touch: @johnbrett <https://twitter.com/johnbrett> | linkedin.com/in/johnbrett1
@johnbrett It works for me. I also got the way with headers Params in this Both works for me now Thank so much.
@johnbrett i am using auth token in REST Api where their is a bug that if the user tries to logIn from 2 different devices at the same time fully synchronised the user get logged in both the device. This is most probably due to the time parameter it uses to create the token. So i was wondering how can i give this time as milliseconds to make it unique.
I'm not sure I follow the issue @ankitlp...is the issue with the hapi-auth-bearer-token library? That library doesn't create auth tokens for you, that is something you are doing yourself. You'll have to elaborate more on how your tokens are created before I can help.
Hi John, I was looking at your plugin of hapi-auth-bearer-token and I have some questions to understand (I'm new in hapi.js). I'm making a RESTful service.
I register the app in a file auth.js