NAME
Amon2::Auth::Site::Github - Github integration for Amon2
SYNOPSIS
__PACKAGE__->load_plugin('Web::Auth', {
module => 'Github',
on_finished => sub {
my ($c, $token, $user) = @_;
my $name = $user->{name} || die;
$c->session->set('name' => $name);
$c->session->set('site' => 'github');
return $c->redirect('/');
}
});
DESCRIPTION
This is a github authentication module for Amon2. You can call a github APIs with this module.
ATTRIBUTES
- client_id
- client_secret
- scope
-
API scope in string.
- user_info(Default: true)
-
Fetch user information after authenticate?
- ua(instance of LWP::UserAgent)
-
You can replace instance of LWP::UserAgent.
METHODS
$auth->auth_uri($c:Amon2::Web, $callback_uri : Str) :Str
-
Get a authenticate URI.
$auth->callback($c:Amon2::Web, $callback:HashRef) : Plack::Response
-
Process the authentication callback dispatching.
$callback
MUST have two keys.- 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.
The arguments are following:
sub { my ($c, $access_token, $user) = @_; ... }
$user
contains user information. This code contains a information like https://api.github.com/users/dankogai.If you set
$auth->user_info
as false value, authentication engine does not pass$user
.