Hapi Bell Twitter Auth发送电子邮件

时间:2016-10-07 11:15:12

标签: twitter hapijs joi

我很难在登录时获取Twitter用户的电子邮件地址

我从Joi得到以下错误"错误:未捕获错误:无效选项值:必须为true,falsy或对象"

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
});

1 个答案:

答案 0 :(得分: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应用程序设置中允许必要的权限(请求用户发送电子邮件地址)。