|
NAMELWP::Authen::OAuth2::ServiceProvider::Line - Access Line OAuth2 API v2 VERSIONversion 0.20 SYNOPSIS my $oauth2 = LWP::Authen::OAuth2->new(
service_provider => 'Line',
redirect_uri => 'http://example.com/',
client_id => 'line_client_id' # Retrieved from https://developers.line.me/
client_secret => 'line_client_secret' # Retrieved from https://developers.line.me/
);
my $url = $oauth2->authorization_url(state => $state);
# ... Send user to authorization URL and get authorization $code ...
$oauth2->request_tokens(code => $code);
# Simple requests
# User Info
my $profile = $oauth2->make_api_call('profile');
my $userId = $profile->{userId};
my $displayName = $profile->{displayName};
my $pictureUrl = $profile->{pictureUrl};
my $statusMessage = $profile->{statusMessage};
# Refresh
$oauth2->refresh_access_token();
# More complex requests...
# Verify
# Manually send the request using the internal user agent - see explanation in "Line API Documentation" below.
my $access_token_str = $oauth2->access_token->access_token;
my $res = $oauth2->user_agent->post($oauth2->api_url_base.'oauth/verify' => { access_token => $access_token_str });
my $content = eval { decode_json($res->content) };
my $scope = $content->{scope};
my $client_id = $content->{client_id};
my $expires_in = $content->{expires_in};
# Revoke
# Look up the internal refresh token - see explanation in "Line API Documentation" below.
my $refresh_token_str = $oauth2->access_token->refresh_token;
$oauth2->post($oauth2->api_url_base.'oauth/revoke' => { refresh_token => $refresh_token_str });
REGISTERINGIndividual users must have an account created with the Line application <https://line.me/download>. In order to log in with OAuth2, users must register their email address. Device-specific instructions can be found on the Line support site <https://help.line.me/>. API clients can follow the Line Login <https://developers.line.me/line-login/overview> documentation to set up the OAuth2 credentials. Line API DocumentationSee the Line Social REST API Reference <https://devdocs.line.me/en/#how-to-use-the-apis>. As of writing, there are two simple API calls: "profile" and "refresh". There are also "verify" and "revoke" endpoints, which require a bit more work.
Refresh timingLine access tokens can be refreshed at any time up until 10 days after the access token expires. The LWP::Authen::OAuth2::ServiceProvider::Line::AccessToken token class used by this service provider extends the "should_refresh" method for this purpose, causing "$oauth2->should_refresh()" to return false if this 10-day period has lapsed. AUTHORAdam Millerchip, "<adam at millerchip.net>" AUTHORS
COPYRIGHT AND LICENSEThis software is copyright (c) 2013 - 2022 by Ben Tilly, Rent.com, Thomas Klausner. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|