LINE Login 開發:以Line 帳號驗證登入網站– 我,傑夫。開發人 | line login教學
設定登入Linedevelopers(https://developers.line.me/en/[1]),選StartusingLINELogin登入,用自己的Line帳號登入(之後每次登入這個平台,會驗證帳號),進入Console(https://developers.line.me/console/register/messaging-api/provider/[2])下一步是建立Provider資料,即發布者(你)想要呈現的資料。點選Addnewprovider,輸入Providername接著選擇LINELogin比較重要的是,填寫Appname,Appdescription,Apptype勾選UseWEB填寫完,勾選同意,並創建。完成後會出現以下畫面,點選箭頭進入。這裡最重要的是ChannelID和Channelsecret,之後...
設定登入Line developers (https://developers.line.me/en/[1]),選 Start using LINE Login 登入,用自己的 Line 帳號登入(之後每次登入這個平台,會驗證帳號),進入 Console (https://developers.line.me/console/register/messaging-api/provider/[2])
下一步是建立 Provider資料,即發布者(你)想要呈現的資料。
點選 Add new provider,輸入 Provider name
接著選擇 LINE Login
比較重要的是,填寫 App name, App description, App type 勾選 Use WEB
填寫完,勾選 同意,並創建。
完成後會出現以下畫面,點選箭頭進入。
這裡最重要的是 Channel ID 和 Channel secret,之後會用到。
然後,到 app settings 進行設定。
設定從 Line 返回網站的網址。這一步,很重要。之後做驗證,Line 會檢查實際返回的網址是不是與這裡相同。
程式Line Login 驗證分二階段:第一先取得授權碼 Authorization code,利用這個授權碼取得 user 資料。
一、取得授權碼 code導向至以下網址:
request 必要參數:
response_type:code 會回傳參數名 code 的授權碼 client_id:你的ChannelID redirect_uri:在Line developer 的設定 state:自訂驗證碼,隨便你填 scope:你想要取得 User 的資料,例如想取得 openid 和 profile,填寫 openid%20profile用戶被導向 Line 的登入畫面,輸入帳密,同意授權後,會返回你的主機,攜帶授權碼。
以下是程式碼: