Amon2::Auth::Site::Hatena - Hatena authentication integration for Amon2
# config +{ Auth => { Hatena => { consumer_key => 'your consumer key', consumer_secret => 'your consumer secret', } } } # app __PACKAGE__->load_plugin('Web::Auth', { module => 'Hatena', on_error => sub { my ($c, $error_message) = @_; ... }, on_finished => sub { my ($c, $token, $token_secret, $user) = @_; my $name = $user->{url_name}; #=> eg. antipop (id) my $nick = $user->{display_name}; #=> eg. kentaro (nick) my $image = $user->{profile_image_url}; $c->session->set(hatena => { user => $user, token => $token, token_secret => $token_secret, }); $c->redirect('/'); }, });
This is a Hatena authentication module for Amon2. You can easily let users authenticate via Hatena OAuth API using this module.
[qw(read_public)]
API scope in ArrayRef.
If true, this module fetch user data immediately after authentication.
$auth->auth_uri($c:Amon2::Web, $callback_uri:Str)
Returns an authenticate URI according to $ENV{HTTP_USER_AGENT}. It can be one of three for PC, smart phone, and JP cell phone.
$ENV{HTTP_USER_AGENT}
$auth->callback($c:Amon2::Web, $callback:HashRef)
Process the authentication callback dispatching.
on_error
on_error callback function is called if an error was occurred.
The arguments are following:
sub { my ($c, $error_message) = @_; ... }
on_finished
on_finished callback function is called if an authentication was finished.
sub { my ($c, $access_token, $access_token_secret, $user) = @_; ... }
$user contains user information. If you set $auth-user_info> as a false value, authentication engine does not pass $user.
$user
$auth-
See "app.psgi" in eg for details.
Hatena Auth Specification
http://developer.hatena.ne.jp/ja/documents/auth
Kentaro Kuribayashi <kentarok@gmail.com>
Copyright (C) Kentaro Kuribayashi
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Amon2::Auth::Site::Hatena, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Amon2::Auth::Site::Hatena
CPAN shell
perl -MCPAN -e shell install Amon2::Auth::Site::Hatena
For more information on module installation, please visit the detailed CPAN module installation guide.