我正在使用passportjs Oauth进行身份验证,获得访问令牌并刷新令牌作为响应。
问题是访问令牌在14天后过期,因此身份验证在14天后失败。
我想知道如何使用Basecamp API使用“刷新令牌”更新访问令牌?
const BasecampStrategy = require('passport-basecamp').Strategy;
const basecampUser = require('../models/basecampUser');
const passport = require('passport');
const keys = require('./keys');
passport.serializeUser(function (user, done) {
done(null, user);
});
passport.deserializeUser(function (user, done) {
done(null, user);
});
const passportConfig = {
clientID: keys.basecamp_dev.clientID,
clientSecret: keys.basecamp_dev.clientSecret,
callbackURL: '/auth/basecamp/callback'
};
passport.use(
new BasecampStrategy(passportConfig, (accessToken, refreshToken, profile, done) => {
db_schema.findOne({ basecampId: profile.id }).then((currentUser) => {
if (currentUser) {
done(null, currentUser);
} else {
new basecampUser({
//
Some feild
............
//
})
.save()
.then((newUser) => {
done(null, newUser);
});
}
});
})
);