mirror of
https://github.com/hardillb/node-red-alexa-home-skill-web.git
synced 2026-01-06 04:33:29 +01:00
Working!!!!
This commit is contained in:
15
oauth.js
15
oauth.js
@@ -6,6 +6,8 @@ var server = oauth2orize.createServer();
|
||||
server.grant(oauth2orize.grant.code({
|
||||
scopeSeparator: [ ' ', ',' ]
|
||||
}, function(application, redirectURI, user, ares, done) {
|
||||
//console.log("grant user: ", user);
|
||||
|
||||
var grant = new OAuth.GrantCode({
|
||||
application: application,
|
||||
user: user,
|
||||
@@ -21,14 +23,24 @@ server.exchange(oauth2orize.exchange.code({
|
||||
}, function(application, code, redirectURI, done) {
|
||||
OAuth.GrantCode.findOne({ code: code }, function(error, grant) {
|
||||
if (grant && grant.active && grant.application == application.id) {
|
||||
//console.log("exchange user ", grant.user);
|
||||
var token = new OAuth.AccessToken({
|
||||
application: grant.application,
|
||||
user: grant.user,
|
||||
grant: grant,
|
||||
scope: grant.scope
|
||||
});
|
||||
|
||||
token.save(function(error) {
|
||||
done(error, error ? null : token.token, null, error ? null : { token_type: 'standard' });
|
||||
|
||||
var refreshToken = new OAuth.RefreshToken({
|
||||
user: grant.user,
|
||||
application: grant.application
|
||||
});
|
||||
|
||||
refreshToken.save(function(error){
|
||||
done(error, error ? null : token.token, refreshToken.token, error ? null : { token_type: 'standard' });
|
||||
});
|
||||
});
|
||||
} else {
|
||||
done(error, false);
|
||||
@@ -36,6 +48,7 @@ server.exchange(oauth2orize.exchange.code({
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
server.serializeClient(function(application, done) {
|
||||
done(null, application.id);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user