Mojolicious-Plugin-Web-Auth

 view release on metacpan or  search on metacpan

lib/Mojolicious/Plugin/Web/Auth.pm  view on Meta::CPAN

  # 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',
  );

=head1 DESCRIPTION

L<Mojolicious::Plugin::Web::Auth> is an authentication plugin for L<Mojolicious>.

=head1 METHODS

L<Mojolicious::Plugin::Web::Auth> inherits all methods from L<Mojolicious::Plugin>.

=head1 OPTIONS

L<Mojolicious::Plugin::Web::Auth> supports the following options.

=head2 C<module>

This is a module name for authentication plugins.

Dropbox, Facebook, Github, Google, Instagram, Twitter.

=head2 C<key>

Consumer key.

=head2 C<secret>

Consumer secret.

=head2 C<scope>

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 ) = @_;
          ...
      };

=head2 C<validate_state>

Optional: OAuth 2.0 only. Default value is 1, see L<http://tools.ietf.org/html/rfc6819#section-5.3.5>.


=head2 C<on_finished>

  # 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.

=head3 arguments

=over 4

=item * OAuth 1.0(A)

Dropbox, Twitter, etc.

=over 4

=item Mojolicious::Controller

=item access_token

=item access_secret

=item user_info ( enabled 'user_info' )

=back

=item * OAuth 2.0

Facebook, Github, Google, Instagram, etc.

=over 4

=item Mojolicious::Controller

=item access_token

=item user_info ( enabled 'user_info' )

=item rest of the response data (HASHREF)

id_token, expires, refresh_token, etc.

=back

=back

=head2 C<on_error>



( run in 2.030 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )