Perl 使用谷歌认证的Mojolicous应用程序,插件OAuth2
我正在使用它构建一个简单的应用程序,您可以使用您的google+凭据登录,但我在语法方面遇到了问题 我的代码与他们给出的示例非常接近:Perl 使用谷歌认证的Mojolicous应用程序,插件OAuth2,perl,oauth-2.0,google-authentication,mojolicious,Perl,Oauth 2.0,Google Authentication,Mojolicious,我正在使用它构建一个简单的应用程序,您可以使用您的google+凭据登录,但我在语法方面遇到了问题 我的代码与他们给出的示例非常接近: use Mojolicious::Lite; use Mojolicious::Plugin::OAuth2; plugin 'OAuth2' => { google => { key => 'xxxxxx.apps.googleusercontent.com', secret => 'xxxxxxxx', },
use Mojolicious::Lite;
use Mojolicious::Plugin::OAuth2;
plugin 'OAuth2' => {
google => {
key => 'xxxxxx.apps.googleusercontent.com',
secret => 'xxxxxxxx',
},
};
get "/auth" => sub {
my $self = shift;
$self->delay(
sub {
my $delay = shift;
$self->get_token(google => $delay->begin, scope->profile)
},
sub {
my($delay, $token, $tx) = @_;
return $self->render(text => $tx->res->error) unless $token;
$self->session(token => $token);
$self->render(text => $token);
},
);
};
app->start;
问题区域是范围->配置文件
。在没有指定作用域的情况下,我从google得到一个错误,说“400:error:invalid_request缺少必需的参数:scope”,但我不能完全正确地得到它,现在收到语法错误
文档中说这样做
$token=$c->get\u token($provider\u name=>\%args)代码>那么如何编写args散列以使其有意义呢?这种语法对我来说很有用
$self->get_token('google', scope => 'profile', $delay->begin);
我不得不把$delay->begin
放在末尾,谷歌在引号里