Аутентификация Hapi Bell в Твиттере по электронной почте

Я изо всех сил пытаюсь получить адрес электронной почты пользователей Twitter, когда они входят в систему

Я получаю следующую ошибку от Joi «Ошибка: неперехваченная ошибка: недопустимое значение параметра: должно быть истинным, ложным или объектом»

server.auth.strategy('twitter', 'bell', {
    provider: 'twitter',
    scope: ['public_profile', 'email'],
    config: {
        extendedProfile: true,
        getParams: 'include_email',
        getMethod: 'account/verify'
    },
    password: config.longpass, //Use something more secure in production
    clientId: config.twitter_key,
    clientSecret: config.twitter_secret,
    isSecure: config.useHttps //Should be set to true (which is the default) in production
});

person David Jennings    schedule 07.10.2016    source источник


Ответы (1)


Этот код работает для меня.

server.auth.strategy('twitter', 'bell', {
    provider: 'twitter',
    config: {
        getMethod: 'account/verify_credentials',
        getParams: {include_email:'true' },//doesn't work without quotes!
    },
    password: 'secret_cookie_encryption_password', //Use something more secure in production
    clientId: secret.twitterId,
    clientSecret: secret.twitterSecret,
    isSecure: false //Should be set to true (which is the default) in production
});

Не забудьте разрешить необходимое разрешение (запрашивать адреса электронной почты у пользователей) в настройках приложения Twitter.

person AlexChet    schedule 18.11.2016