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:

  1. authenticate user in application using passport's local strategy
  2. manually generate smartthings' authorization code , token - guide here
  3. save token in user's session

after can use token in session make requests smartthings' api


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -