Getting user profiles

You can use the LINE SDK for Android to get a user’s LINE profile information. User profiles include a user's user ID, display name, profile media (image or video), and status message.

Before you begin

Make sure you have completed the following:

Getting user profile information

To get a user's LINE profile information, call the getProfile method. The method returns a LineApiResponse object containing LineProfile. When getProfile is called, the SDK automatically checks the validity of the access token. If the access token has expired, the SDK calls the refresh token method. If the token cannot be refreshed, an error response is returned and you must prompt the user to log in again.

The following is an example of how to get a user's profile and save the data into strings.

LineApiResponse apiResponse = lineApiClient.getProfile();

String displayName = apiResponse.getResponseData().getDisplayName();
String pictureURL = apiResponse.getResponseData().getPictureUrl().toString();
String userID = apiResponse.getResponseData().getUserId().toString();
String statusMessage = apiResponse.getResponseData().getStatusMessage();

You can change the size of the user’s profile image by adding a suffix to the URL.

Image Size Suffix
200 x 200 /large
51 x 51 /small

Handling errors

The following HTTP status codes are returned when an API is called.

Status code Description
200 OK Request successful
400 Bad Request Problem with the request. Check the request parameters and JSON format.
401 Unauthorized Check that the authorization header is correct.
403 Forbidden Not authorized to use the API. Confirm that your account or plan is authorized to use the API.
429 Too Many Requests Make sure that you are within the rate limits for requests.
500 Internal Server Error Temporary error on the API server.

{{ $t("form.question.helpful") }}

{{ $t("form.question.detail") }}

{{ $t("form.question.improve") }}

{{ $t("form.info.start") }}{{ $t("form.info.link") }}{{ $t("form.info.end") }}


{{ $t("form.result.success") }}
{{ $t("form.result.error") }}
{{ $t("form.result.errorLink") }}