NAME
Amon2::Auth::Site::Facebook - Facebook integration for Amon2
SYNOPSIS
__PACKAGE__->load_plugin('Web::Auth', {
module => 'Facebook',
on_finished => sub {
my ($c, $token, $user) = @_;
my $name = $user->{name} || die;
$c->session->set('name' => $name);
$c->session->set('site' => 'facebook');
return $c->redirect('/');
}
});
DESCRIPTION
This is a facebook authentication module for Amon2. You can call a facebook APIs with this module.
ATTRIBUTES
- client_id
- client_secret
- scope
-
API scope in string.
- user_info(Default: true)
-
Fetch user information after authenticate?
- fields(Default: "id,name")
-
need fields of user information https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-public_profile
- 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://graph.facebook.com/19292868552.If you set
$auth->user_info
as false value, authentication engine does not pass$user
.