Hi All,

Want to create login with amazon functionality  but getting below error,

We're sorry!
An error occurred when we tried to process your request. Rest assured, 
we're already working on the problem and expect to resolve it shortly.  

Pls help......

layout.ejs

a href="/auth/amazon">Login with Amazon</a>


var express = require('express')
  , passport = require('passport')
  , util = require('util')
  , AmazonStrategy = require('passport-amazon').Strategy;

var https = require('https');

var fs = require('fs');
var options = {
    key: fs.readFileSync('/etc/apache2/ssl/apache.key'),
    cert: fs.readFileSync('/etc/apache2/ssl/apache.crt')
};


/*https.createServer(options, function (req, res) {
    res.end('secure!');
}).listen(443);*/

var AMAZON_CLIENT_ID = "amzn1.application.20d2f3b915c44f298f1f04512cb9cf15"
var AMAZON_CLIENT_SECRET = 
"53bb525ada19759df67994892c63793764589b1906d571ca7b133aa5fb76f71f";

passport.serializeUser(function(user, done) {
  done(null, user);
});

passport.deserializeUser(function(obj, done) {
  done(null, obj);
});

passport.use(new AmazonStrategy({
    clientID: AMAZON_CLIENT_ID,
    clientSecret: AMAZON_CLIENT_SECRET,
    callbackURL: "https://localhost:3000/auth/amazon/callback";
  },
  function(accessToken, refreshToken, profile, done) {
    // asynchronous verification, for effect...
    console.log("access token is" + accessToken)
    console.log("access token is" + profile)

    process.nextTick(function () {

   
      console.log("profile  is" + profile)
      return done(null, profile);
    });
  }
));

var app = express.createServer(options).listen(443);
//var httpsserver = https.createServer(options, app)

// configure Express
app.configure(function() {
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.logger());
  app.use(express.cookieParser());
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.session({ secret: 'keyboard cat' }));

  app.use(passport.initialize());
  app.use(passport.session());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});


app.get('/', function(req, res){
  res.render('index', { user: req.user });
});

app.get('/account', ensureAuthenticated, function(req, res){
  res.render('account', { user: req.user });
});

app.get('/login', function(req, res){
  res.render('login', { user: req.user });
});

app.get('/auth/amazon',
  passport.authenticate('amazon', { scope: ['profile', 'postal_code'] }),
  function(req, res){
    // The request will be redirected to Amazon for authentication, so this
    // function will not be called.
  })

app.get('/auth/amazon/callback',
  passport.authenticate('amazon', { failureRedirect: '/login' }),
  function(req, res) {
    res.redirect('/');
  });

app.get('/logout', function(req, res){
  req.logout();
  res.redirect('/');
});

function ensureAuthenticated(req, res, next) {
  if (req.isAuthenticated()) { return next(); }
  res.redirect('/login')
}




-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b5a5c04d-c4b1-4ce2-82c2-df80ff854855%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to