PrePAN

Sign in to PrePAN

Amon2::Auth::Site::Hatena Hatena Auth integration for Amon2

Good

Synopsis

# 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) = @_;
        die $error_message;
    },
    on_finished => sub {
        my ($c, $token, $token_secret, $user) = @_;
        $c->session->set(auth_hatena => {
            user         => $user,
            token        => $token,
            token_secret => $token_secret,
        });

        $c->redirect('/');
    },
});

Description

Amon2::Auth handler for Hatena auth (Hatena OAuth Spec.).

It might be better for the code to be directly in Amon2::Auth distribution. Should I send a pull-req rather than creating such an independent distribution? > @tokuhirom

  • TODO
    • tests (but, what the best practice on that kind of test?)
    • document

See also: http://d.hatena.ne.jp/antipop/20111017/1318866609

Comments

Release it!
Just shipped. Thanks!

Please sign up to post a review.