This is going to be quite a broad question as I am stuck where to really start. I'm trying to authenticate with SmartThings using Passport. Looking at the SmartThings documentation here: http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/tutorial-part2.htm
SmartThings doesn't return any user information, simply an authentication token you then use to make calls to your SmartThings instance to control the environment.
I'm currently trying to use the OAuth2 Strategy, however this expects a user profile to be returned to serialise the user, which in this instance is null.
What I am trying to achieve is for someone to authorise with SmartThings and store their token in a session so that their data can be pulled.
Long term I will assign it to a user account local to my application, however for now, I'd just like to get the above working.
Does anyone know how I am best going about this. I am somewhat struggling with this.. perhaps using the OAuth2 Strategy isn't the right way to go about it? I currently 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());
}
}