登入 LINE Developers 的 Console
https://developers.line.biz/zh-hant/
參考相關文件:https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request
https://access.line.me/oauth2/v2.1/authorize (登入連結)
URL => https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id=xxxxx&redirect_uri=http://www.xxxx.com/LINE/test.php&state=12345abcde&scope=profile
Response => http://www.xxxx.com/LINE/test.php?code=xxxxx&state=12345abcde
https://api.line.me/oauth2/v2.1/token (取得Access Token)
POST https://api.line.me/oauth2/v2.1/token
'Content-Type: application/x-www-form-urlencoded' \
'grant_type=authorization_code' \
'code={code}' \
'redirect_uri=xxx' \
'client_id=xxx' \
'client_secret=xxx'
Response:
{
"access_token": "bNl4YEFPI/hxxxxx4MuEw5YPs...",
"expires_in": 2592000,
"id_token": "eyJhbxxxxzI1NiJ9...",
"refresh_token": "Aa1FdegxxxxNNpxr8p",
"scope": "profile",
"token_type": "Bearer"
}
https://api.line.me/v2/profile (取得登入者資料)
GET https://api.line.me/v2/profile
authorization: Bearer {access_token}
Response:
{
"userId": "Ub7cbecaxxxxeb8cac130fd883xxxx9",
"displayName": "xxx",
"pictureUrl": "https://profile.line-scdn.net/0h73FRgMeEaBx7xxxxpp0XS0duZxxxxxe115ZH5VS31IQkkkcgstYy9fS30ZRk0if18jP3kE"
}