こちらの記事を参考に構築後
2018年10月21日現在の最新のバージョン
それぞれ以下
Socalite3.0
Laravel5.5
LINEログインv2
で動作するよう
LineProvider.phpを書き換えました。
LineProvider.php
<?php
namespace App\Socialite;
use Laravel\Socialite\Two\AbstractProvider;
use Laravel\Socialite\Two\ProviderInterface;
use Laravel\Socialite\Two\User;
class LineProvider extends AbstractProvider implements ProviderInterface
{
protected function getAuthUrl($state)
{
return $this->buildAuthUrlFromBase('https://access.line.me/dialog/oauth/weblogin', $state);
}
protected function getTokenUrl()
{
return 'https://api.line.me/v2/oauth/accessToken/';
}
public function getAccessTokenResponse($code)
{
$response = $this->getHttpClient()->post($this->getTokenUrl(), [
'headers' => ['Accept' => 'application/json'],
'form_params' => [
'grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => $this->redirectUrl,
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret
],
]);
return json_decode($response->getBody(), true);
}
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get('https://api.line.me/v2/profile', [
'headers' => [
'Authorization' => 'Bearer '.$token,
],
]);
return json_decode($response->getBody(), true);
}
protected function mapUserToObject(array $user)
{
return (new User())->setRaw($user)->map([
'id' => $user['userId'],
'name' => $user['displayName'],
'pictureUrl' => $user['pictureUrl'],
]);
}
}