Amon2-Auth-Site-LINE

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

                sub {
                    my ($c, $access_token, $api_response) = @_;
                    ...
                }

            $api_response contains an issued access token, a verified access
            token validity, and a gotten user profile. And they are all
            merged into one hash-ref. This code contains a information like
            <https://developers.line.biz/en/reference/line-login/#issue-toke
            n-response>,
            <https://developers.line.biz/en/reference/line-login/#verify-acc
            ess-token-response> and
            <https://developers.line.biz/en/reference/line-login/#get-profil
            e-response>. If you set "$auth->user_info" as a false value
            and/or you don't set "profile" as the "scope" attribute,
            authentication engine does not pass a gotten user profile.

AUTHOR
    Koichi Taniguchi (a.k.a. nipotan) <taniguchi@cpan.org>

LICENSE

README.md  view on Meta::CPAN

        on\_finished callback function is called if an authentication was finished.ck function is called After successful authentication.

        The arguments are following:

            sub {
                my ($c, $access_token, $api_response) = @_;
                ...
            }

        `$api_response` contains an issued access token, a verified access token validity, and a gotten user profile. And they are all merged into one hash-ref.
        This code contains a information like [https://developers.line.biz/en/reference/line-login/#issue-token-response](https://developers.line.biz/en/reference/line-login/#issue-token-response), [https://developers.line.biz/en/reference/line-login...
        If you set `$auth->user_info` as a false value and/or you don't set `profile` as the `scope` attribute, authentication engine does not pass a gotten user profile.

# AUTHOR

Koichi Taniguchi (a.k.a. nipotan) <taniguchi@cpan.org>

# LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

lib/Amon2/Auth/Site/LINE.pm  view on Meta::CPAN

    isa     => 'Str',
    default => 'https://access.line.me/oauth2/v2.1/authorize',
);

has access_token_url => (
    is      => 'ro',
    isa     => 'Str',
    default => 'https://api.line.me/oauth2/v2.1/token',
);

has verify_url => (
    is      => 'ro',
    isa     => 'Str',
    default => 'https://api.line.me/oauth2/v2.1/verify',
);

has profile_url => (
    is      => 'ro',
    isa     => 'Str',
    default => 'https://api.line.me/v2/profile',
);

has ua => (
    is      => 'ro',

lib/Amon2/Auth/Site/LINE.pm  view on Meta::CPAN

        });
        unless ($res->is_success) {
            warn $res->decoded_content;
            return $callback->{on_error}->($res->status_line);
        }

        $token_data = decode_json($res->content);
        %api_response = (%api_response, %$token_data);
    }

    # verify access token
    my $verify_data;
    {
        my $uri = URI->new($self->verify_url);
        $uri->query_form(access_token => $token_data->{access_token});

        my $res = $self->ua->get($uri->as_string);
        unless ($res->is_success) {
            warn $res->decoded_content;
            return $callback->{on_error}->($res->status_line);
        }

        $verify_data = decode_json($res->content);
        if ($verify_data->{client_id} ne $self->client_id) {
            return $callback->{on_error}->('client_id mismatch');
        }

        push @args, $token_data->{access_token};
        %api_response = (%api_response, %$verify_data);
    }

    # get user profile
    if ($self->user_info && $verify_data->{scope} =~ /\bprofile\b/) {
        my $uri = URI->new($self->profile_url);
        my $res = $self->ua->get(
            $uri->as_string,
            Authorization => 'Bearer ' . $token_data->{access_token},
        );
        $res->is_success or do {
            warn $res->decoded_content;
            return $callback->{on_error}->($res->decoded_content);
        };
        my $user = decode_json($res->content);

lib/Amon2/Auth/Site/LINE.pm  view on Meta::CPAN

on_finished callback function is called if an authentication was finished.ck function is called After successful authentication.
 
The arguments are following:
 
    sub {
        my ($c, $access_token, $api_response) = @_;
        ...
    }

C<< $api_response >> contains an issued access token, a verified access token validity, and a gotten user profile. And they are all merged into one hash-ref.
This code contains a information like L<https://developers.line.biz/en/reference/line-login/#issue-token-response>, L<https://developers.line.biz/en/reference/line-login/#verify-access-token-response> and L<https://developers.line.biz/en/reference/li...
If you set C<< $auth->user_info >> as a false value and/or you don't set C<< profile >> as the C<< scope >> attribute, authentication engine does not pass a gotten user profile.
 
=back
 
=back

=head1 AUTHOR
 
Koichi Taniguchi (a.k.a. nipotan) E<lt>taniguchi@cpan.orgE<gt>
 



( run in 0.348 second using v1.01-cache-2.11-cpan-5467b0d2c73 )