node.js - Passport & SmartThings -
this going quite broad question stuck start. i'm trying authenticate smartthings using passport. looking @ smartthings documentation here: http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/tutorial-part2.htm
smartthings doesn't return user information, authentication token use make calls smartthings instance control environment.
i'm trying use oauth2 strategy, expects user profile returned serialise user, in instance null.
what trying achieve authorise smartthings , store token in session data can pulled.
long term assign user account local application, now, i'd above working.
does know how best going this. struggling this.. perhaps using oauth2 strategy isn't right way go it? have this:
var passport = require('passport'); var oauth2strategy = require('passport-oauth2').strategy; var verifyhandler = function(req, token, refreshtoken, profile, done){ return done(token) } passport.serializeuser(function(user, done) { done(null, user.id); }); module.exports.http = { custommiddleware: function(app) { passport.use(new oauth2strategy({ authorizationurl: 'https://graph.api.smartthings.com/oauth/authorize', tokenurl: 'https://graph.api.smartthings.com/oauth/token', clientid: '123', clientsecret: 'abc', callbackurl: 'http://localhost:1337/auth/smartthings/callback', skipuserprofile: true, passreqtocallback: true }, verifyhandler)); app.use(passport.initialize()); app.use(passport.session()); } }
i think want in authentication process:
- authenticate user in application using passport's
local
strategy - manually generate smartthings' authorization code , token - guide here
- save token in user's session
after can use token
in session make requests smartthings' api
Comments
Post a Comment