Converting an MID to a user ID

Users are identified using a user ID in LINE Login v2 or later instead of an MID in v1. If you have integrated LINE Login v1 into your app and want to migrate it to v2 or later, take the following steps to convert MIDs to user IDs. This operation is allowed only for channels created before LINE Login v2 was released.

  1. Get an access token to access the endpoint for converting an MID.
  2. Use the access token obtained in the previous step to convert an MID to a user ID.

Converted user IDs are only valid for channels under the same provider.

Getting an access token

To get an access token, make an HTTP POST request to the following endpoint with the information of your current LINE Login channel.

HTTP Request

POST https://api.line.me/v2/oauth/accessToken

Request header

Request header Description
Content-Type application/x-www-form-urlencoded

Request body

Parameters Type Required Description
grant_type String Required client_credentials
client_id String Required Channel ID. Found in the console.
client_secret String Required Channel secret. Found in the console.

Example request with cURL

curl -X POST https://api.line.me/v2/oauth/accessToken \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials' \
-d 'client_id={channel ID}' \
-d 'client_secret={channel secret}'

Response

Property Type Description
access_token String Access token. Valid for 30 days.
expires_in Number Amount of time in seconds until the access token expires.
token_type String Bearer

The following is an example JSON response. Use the access_token value when calling the conversion API.

{
    "access_token":"{access token}",
    "expires_in":2592000,
    "token_type":"Bearer"
}

Converting an MID to a user ID

To convert an MID to a user ID, make an HTTP GET request to the following endpoint with the access token obtained in the previous step.

HTTP Request

GET https://api.line.me/v2/bot/dedisco/migration/userId

Request header

Request header Description
Authorization Bearer {access token}

Query parameters

Parameters Type Required Description
mid String Required MID to convert. The MID value is a string that matches the regular expression, u[0-9a-f]{32}.

Example request with cURL

curl -X GET https://api.line.me/v2/bot/dedisco/migration/userId?mid={mid to convert} \
-H 'Authorization: Bearer {access token}'

Response

Returns a user ID converted from the MID. The user ID value is a string that matches the regular expression, U[0-9a-f]{32}.

{user id}

Converting multiple MIDs in bulk

To convert multiple MIDs in bulk, make an HTTP GET request to the following endpoint.

HTTP Request

POST https://api.line.me/v2/bot/dedisco/migration/userId/getbulk

Request header

Request header Description
Authorization Bearer {access token}
Content-Type text/plain

Request body

MID to convert. The MID value is a string that matches the regular expression, u[0-9a-f]{32}. Specify one MID per line. The maximum size of the request body of this API call is 3.5 MB. You can convert multiple MIDs in bulk within this limit.

Example request with cURL

curl -X POST https://api.line.me/v2/bot/dedisco/migration/userId/getbulk \
-H 'Authorization: Bearer {access token}' \
-H 'Content-Type: text/plain' \
-d '{mid to convert 1}
{mid to convert 2}'

Response

Returns each pair of an MID and a converted user ID, one per line. The user ID value is a string that matches the regular expression, U[0-9a-f]{32}.

{mid 1} {user id 1}
{mid 2} {user id 2}