Mojolicious::Plugin::Web::Auth - Authentication plugin for Mojolicious
# Mojolicious
$self->plugin('Web::Auth',
module => 'Twitter',
key => 'Twitter consumer key',
secret => 'Twitter consumer secret',
on_finished => sub {
my ( $c, $access_token, $access_secret ) = @_;
...
},
);
# Mojolicious::Lite
plugin 'Web::Auth',
module => 'Twitter',
key => 'Twitter consumer key',
secret => 'Twitter consumer secret',
on_finished => sub {
my ( $c, $access_token, $access_secret ) = @_;
...
};
### default authentication endpoint: /auth/{moniker}/authenticate
# e.g.)
# /auth/twitter/authenticate
# /auth/facebook/authenticate
### default callback endpoint: /auth/{moniker}/callback
# e.g.)
# /auth/twitter/callback
# /auth/facebook/callback
# If, for example, your Instagram app needs more permissions than the
# defaults allow:
# Mojolicious
$self->plugin('Web::Auth',
module => 'Instagram',
key => 'Instagram consumer key',
secret => 'Instagram consumer secret',
on_finished => sub {
my ( $c, $access_token, $access_secret ) = @_;
...
},
authorize_url => 'https://api.instagram.com/oauth/authorize?scope=public_content',
);
Mojolicious::Plugin::Web::Auth is an authentication plugin for Mojolicious.
Mojolicious::Plugin::Web::Auth inherits all methods from Mojolicious::Plugin.
Mojolicious::Plugin::Web::Auth supports the following options.
This is a module name for authentication plugins.
Dropbox, Facebook, Github, Google, Instagram, Twitter.
Consumer key.
Consumer secret.
Optional: OAuth 2.0 only.
# Facebook
plugin 'Web::Auth',
module => 'Facebook',
key => 'Facebook App ID',
secret => 'Facebook App Secret',
scope => 'email,user_birthday',
on_finished => sub {
my ( $c, $access_token, $user_info ) = @_;
...
};
Optional: OAuth 2.0 only. Default value is 1, see http://tools.ietf.org/html/rfc6819#section-5.3.5.
# Mojolicious::Lite
plugin 'Web::Auth',
module => 'Twitter',
key => 'Twitter consumer key',
secret => 'Twitter consumer secret',
on_finished => sub {
my ( $c, $access_token, $access_secret, $user_ino ) = @_;
...
};
This callback is run when authentication was finished.
-
OAuth 1.0(A)
Dropbox, Twitter, etc.
- Mojolicious::Controller
- access_token
- access_secret
- user_info ( enabled 'user_info' )
-
OAuth 2.0
Facebook, Github, Google, Instagram, etc.
-
Mojolicious::Controller
-
access_token
-
user_info ( enabled 'user_info' )
-
rest of the response data (HASHREF)
id_token, expires, refresh_token, etc.
-
This is a callback is run on authentication errors.
hayajo [email protected]
Many thanks to the contributors for their work.
- FAYLAND
- uzulla@github
- sachinjsk@github
- mala@github
- shohey1226@github
- levonet@github
- oalders@github
- ccakes@github
Copyright 2013- hayajo
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.