question

tliber avatar image
tliber asked

Amazon passport Oauth

I'm trying to use https://github.com/jaredhanson/passport-amazon to authenticate my user's amazon account. When I try go to the amazon page (on-click event for login) my server returns GET /auth/amazon/callback?error=invalid_scope&error_description=An+unknown+scope+was+requested 302 12ms - 68b This is the implementation ` var express = require('express'); var passport = require('passport'); var auth = require('../auth.service'); var router = express.Router(); router.get('/', passport.authenticate('amazon')); router.get('/callback', passport.authenticate('amazon', { failureRedirect: '/login' }), function(req, res) { // Successful authentication, redirect home. res.redirect('/'); });` with the router (`/`) set to auth/amazon This is the strategy `var passport = require('passport'); var AmazonStrategy = require('passport-amazon').Strategy; exports.setup = function(User, config) { console.log(User, config) passport.use(new AmazonStrategy({ clientID: config.amazonOAuth.clientID, clientSecret: config.amazonOAuth.clientSecret, callbackURL: config.amazonOAuth.callbackURL }, function(accessToken, refreshToken, profile, done) { console.log('LOGGED IN') User.findOne({ ' amazon.Id': profile.id }, function(err, user) { if (err) { return done(err); } if (!user) { user = new User({ name: profile.displayName, email: profile.emails[0].value, role: 'user', username: profile.username, provider: 'amazon', facebook: profile._json }); user.save(function(err) { if (err) done(err); return done(err, user); }); } else { return done(err, user); } }) } )); };` I should also mention that we are using the same callback to our amazon cloud service. My account is registered with the developer.amazon.com for amazon login. Thanks in advance
iap
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

DougM@Amazon avatar image
DougM@Amazon answered
Hello tliber, Looking at the login example, one question we would have is are you requesting the exact same scopes as the passport example? Being, account and login? As that is at least what I see when I look at : https://github.com/jaredhanson/passport-amazon/blob/master/examples/login/app.js So, first we would like to know do you have the security profile configured for your web application correctly? Meaning that you created the Security Profile, and then associated it with Login With Amazon, at : https://developer.amazon.com/lwa/sp/overview.html In addition, did you configure the JavaScript origin as well? As that would also be important when determining what is going on. https://developer.amazon.com/public/apis/engage/login-with-amazon/docs/adding_website.html For details as to the user profile scopes: https://developer.amazon.com/public/apis/engage/login-with-amazon/docs/customer_profile.html
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.