Line Login

Line Developer Console

https://developers.line.biz/console/

Steps:

  1. Create a channel in developer console
    1. Apply Open ID and Email permission
    2. Add callback URL
    3. Client ID = Channel ID
  2. Get the link to Line Login Page
    1. Scope is important
      If you use http_build_query() to combine params, just use space to separate scopes.
  3. Get Access Token and ID Token
  4. Get User’s ID via Profile API
    1. access token

Login Example

public function line_login(){
	$url = 'https://access.line.me/oauth2/v2.1/authorize?';
	$params = [];
	$params['response_type'] = 'code';
	$params['client_id'] = '123456';
	$params['redirect_uri'] = 'https://xxx.com/member/line/listener';
	$params['state'] = Str::random(20);
	$params['scope'] = 'openid email profile';
	$params['nonce'] = Str::random(10);
	
	$url .= http_build_query($params);
	//logg($url);
	return redirect($url);
}

Reference: