Неправильная аутентификация на стеке-обмене - паспорт nodejs - PullRequest
0 голосов
/ 29 марта 2019

У меня действительно странная проблема.Позвольте мне объяснить, что произошло.

Я создал с новым приложением Stack Exchange:

clientID xxxxx
name zyrafywchodzadoszafyqqq
OAuth Domain x.xx.xx.xxx
Application Website x.xx.xx.xxx 

В моем приложении nodejs я использую паспорт для авторизации.

passport.serializeUser((user, done) => done(null, user))
passport.deserializeUser((obj, done) => done(null, obj))

const authOptions = {
  clientID: '12345', // appID
  clientSecret: 'aaaaaaaaa', // key 
  callbackURL: 'http://example.com/auth/stack-exchange/callback',
  stackAppsKey: 'generatedkey', // key
  site: 'zyrafywchodzadoszafyqqq'
}

const authStackExchange = (accessToken, refreshToken, profile, done) => {
  process.nextTick(() => {
    return done(null, profile)
  })
}

passport.use(new StackExchangeStrategy(authOptions, authStackExchange))

/*
 * ... some code of express conf
 */

  app.get('/auth/stack-exchange', passport.authenticate('stack-exchange'))
  // Callback url which is set in stackexchange api configuration
  app.get(
    '/auth/stack-exchange/callback',
    passport.authenticate('stack-exchange', { failureRedirect: '/' }),
    (req, res) => {
      const user = req.user
      user.initials = generateInitials(user.displayName)
      // Save user to DB
      r.db('stackboard')
      .table('users')
      .insert(user, { conflict: 'update' })
      .run(connection, (err, result) => { if (err) throw err })
      res.redirect('/')
    }
  )

К сожалениюЯ всегда получаю сообщение об ошибке

{"error_id":400,"error_message":"No site found for name zyrafywchodzadoszafyqqq","error_name":"bad_parameter"}

Узел v11.12.0

Есть идеи?

...