GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
LWP::Authen::OAuth2::ServiceProvider::Line(3) User Contributed Perl Documentation LWP::Authen::OAuth2::ServiceProvider::Line(3)

LWP::Authen::OAuth2::ServiceProvider::Line - Access Line OAuth2 API v2

    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 });

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

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

"verify"
"verify" is designed for verifying pre-existing access tokens. Instead of using the "Authorization" header, this endpoint expects the access token to be form-urlencoded in the request body. Because of this, it's necessary to get access to the internal access token string to send in the request body. The LWP::Authen::OAuth2::ServiceProvider::Line::AccessToken token class used by this service provider provides the "access_token" accessor for this purpose.

The server seems to ignore the "Authorization" header for this request, so including it is probably not a problem. If you want to avoid sending the access token in the header, it's necessary to manually construct the request and decode the response.

See "SYNOPSYS" for usage examples.

"revoke"
"revoke" requires the refresh token to be form-urlencoded in the request body. Because of this, it's necessary to get access to the internal refresh token string to send in the request body. The LWP::Authen::OAuth2::ServiceProvider::Line::AccessToken token class used by this service provider provides the "refresh_token" accessor for this purpose. See "SYNOPSYS" for usage examples.

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

Adam Millerchip, "<adam at millerchip.net>"
2017-08-15 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.