Skip to main content

Registering as a User Using a LINE Account and Adding the Official Account as a Friend

Overview

If you want to register as a user on Kuroco using a LINE account, you can use Kuroco's OAuth SP feature. The OAuth SP feature provides several external services as presets, including LINE.

Image from Gyazo

Using the preset settings makes it easy to configure, but you cannot customize it in detail. For example, if you want to use the LINE message sending feature from Kuroco, it would be convenient if the user registration also automatically adds the LINE official account as a friend. However, this cannot be done with the user registration using the LINE preset settings.

Here, we will explain how to register as a user on Kuroco using LINE account integration and simultaneously add the official account as a friend using the custom settings of Kuroco's OAuth SP feature.

What you will learn

Learn how to make a LINE Official Account a friend when logging in with Kuroco's OAuth SP using the following steps:

Before you start

This page assumes that the provider and channel (Messaging API) have already been set up in the LINE Developers Console. If you haven't set it up yet, please refer to the following tutorial.

Kuroco Configuration

Member Detail Settings

First, configure Kuroco to store LINE ID information to associate it with the member's information. Select "Member Management" from the sidebar, then select "Member Detail Settings" from the dropdown at the top to display the member detail settings screen. Click the "Set extended items for registered members" button.

Image from Gyazo

In the extended item settings screen, add "Line ID" to the member extended items and click the "Update" button.

Image from Gyazo

Group Settings

It is convenient to distinguish users who have registered using LINE accounts from other users. Here, we will create a group called "LINE Users" and assign them to that group. Open the group settings screen, click the "+ Add" button, and enter the following items, then click the "+ Add" button.

ItemSetting
NameLINE User
Enable(checked)
User TypeLogin User
IP Address Restriction(empty)

Image from Gyazo

API Settings

You must have at least one API with dynamic token security.

If you don't have one, please add an API. Open the endpoint list screen, click the "+ Add" button in the upper right corner. In the popup, configure it as follows, then click the "Add" button.

ItemSetting
TitleFor LINE User
Version1.0
DescriptionFor LINE User

Image from Gyazo

Click the [Security] button at the top of the endpoint list screen, select [Dynamic Token] in the [Security] settings on the popup, and click the [Save] button.

Image from Gyazo

Settings on LINE Developers Console

Set the following on the LINE Developers Console:
(1) Provider
(2) Channel (Messaging API)
(3) Channel (LINE Login)

For (1) and (2), please refer to Sending Messages to LINE Users.

Setting for Channel (LINE Login)

Log in to the LINE Developers Console, select [LINE Login] in [New Channel Registration], and enter the information for the service to be provided according to the input form.

Please log in to the LINE Developers Console, select [LINE Login] under [New Channel Registration] from the provider created in Sending Messages to LINE Users, and follow the input form to enter information about the service you are providing.

Image from Gyazo

When you open the settings screen again, a field called [Linked LINE Official Account] will appear.

Image from Gyazo

If the Messaging API channel associated with the LINE Official Account is in the same provider as the LINE Login channel, it will be selectable here. Select the corresponding Messaging API channel and click the [Update] button.

Also, the Channel ID of the created channel will be displayed, so please keep it handy.

Image from Gyazo

Click the [+ Add] button on the OAuth SP settings screen of Kuroco.

Image from Gyazo

Set the form as follows:

ItemSetting
OAuth SP NameSet a descriptive name such as LINE (Add Friend to Official Account)
Target DomainAPI
TypeCustom
Client ID(10-digit integer Channel ID of the LINE Login channel)
Client Secret(empty)
Authorization URLhttps://access.line.me/oauth2/v2.1/authorize?prompt=consent&bot_prompt=aggressive
Token URLhttps://api.line.me/oauth2/v2.1/token
Resource URLhttps://api.line.me/v2/profile
(For API) Generate Grant TokenCheck [For LINE User]
Use Private URL(unchecked)
Return URL (Success)Specify the frontend URL you want to transition to immediately after login
Return URL (Error)(empty)
Enable Automatic User RegistrationEnable: (checked)
Group to be set at registration: LINE Users
IDP Mapping with Registration FieldsMap to First Name: name
Map to Last Name: name
Use Name Splitter: (checked)
Store ID in Member Extended Item Instead of Using EmailEnable: (checked)
IDP OpenID Key: userId
Member Extended Item to Store ID: LINE ID
Required Data Scopeprofile
openId
Scope SeparatorSpace ' '
Save User Access Token(unchecked)
Send Client Secret in Basic Authentication Header(unchecked)
Do Not Send Authorization Prompt Parameters(unchecked)

Setting Callback URL

When you open the external system integration editing screen again, you will see the [Login URL] as shown below, so please keep it handy.

Image from Gyazo

To open the [LINE Login Settings] tab, go to the login channel settings page in the LINE Developer Console. Enter the [Login URL] that you saved earlier in the [Callback URL] field, and click [Update].

Image from Gyazo

That's all for the settings.

Verification

Access the [Login URL] mentioned above using your device or any other means.

Image from Gyazo

After the LINE Login consent screen, you will see the [Add Friend] button.

Image from Gyazo

Clicking the [Add Friend] button will add the official account as a friend and redirect you to the URL set in [Return URL (Success)].


Support

If you have any other questions, please contact us or check out Our Slack Community.