0

我正在努力获取 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
});
4

1 回答 1

0

这段代码对我有用。

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 应用程序设置中允许必要的权限(向用户请求电子邮件地址)。

于 2016-11-18T13:32:41.683 回答