我正在尝试使用 Catalyst::Authentication::Credential::OpenID对来自 Google 的用户进行身份验证。 身份验证成功后,我会收到 Catalyst::Plugin::Authentication::User::Hash对象作为我的用户。 如果用户是第一次在我的应用程序中登录,我想从 OpenID 提供商那里获取用户的详细信息并将它们存储在我的数据库中。 这是为了简化注册过程,我希望从 OpenID 获得尽可能多的详细信息。 但至少名字、姓氏、电子邮件等。
但是我做不到。例如,如果我调用,我会收到异常消息,提示方法 *url、显示 * 未定义。
$c->user->url
$c->user->display
任何有助于解决问题的帮助。
最佳答案
在多次阅读 Catalyst 手册并从 Catalyst 邮件列表中获得一些线索后,我开始知道我们必须使用扩展。
因为我们将使用许多不同的领域,所以我使用了渐进式类。
这是我的应用中使用的示例配置,目前仅支持 openID。
这使用定义在 OpenID 属性交换的简单注册模式 http://www.axschema.org/types/
'Plugin::Authentication' => {
default_realm => 'progressive',
realms => {
progressive => {
class => 'Progressive',
realms => [ 'openid' ],
},
openid => {
credential => {
class => "OpenID",
store => {
class => "OpenID",
},
consumer_secret => "Don't bother setting",
ua_class => "LWP::UserAgent",
# whitelist is only relevant for LWPx::ParanoidAgent
ua_args => {
whitelisted_hosts => [qw/ 127.0.0.1 localhost /],
},
extensions => [
'http://openid.net/srv/ax/1.0' => {
mode => 'fetch_request',
'type.nickname' => 'http://axschema.org/namePerson/friendly',
'type.email' => 'http://axschema.org/contact/email',
'type.fullname' => 'http://axschema.org/namePerson',
'type.firstname' => 'http://axschema.org/namePerson/first',
'type.lastname' => 'http://axschema.org/namePerson/last',
'type.dob' => 'http://axschema.org/birthDate',
'type.gender' => 'http://axschema.org/person/gender',
'type.country' => 'http://axschema.org/contact/country/home',
'type.language' => 'http://axschema.org/pref/language',
'type.timezone' => 'http://axschema.org/pref/timezone',
required => 'nickname,fullname,email,firstname,lastname,dob,gender,country',
if_available => 'dob,gender,language,timezone',
}
],
},
}
}
},
关于perl - Openid - 身份验证后的用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4401821/