3
0

More than 1 year has passed since last update.

LIFFでアカウント連携時にLINEプラットフォームにリダイレクトができない

Posted at

背景

自社IDとLINEアカウントを連携したい。公式リファレンスに従い進めてましたが、終盤工程である ⑨ウェブサーバーが、ユーザーをアカウントを連携するエンドポイントにリダイレクトする。にて詰まりました。

事象

linktoken & nonce取得後にユーザを下記エンドポイントへリダイレクトさせる必要がある

https://access.line.me/dialog/bot/accountLink?linkToken={link token}&nonce={nonce}

しかし、「ログイン中」 と薄っすら画面に何度も表示される現象に陥る。しかもエラー表示もでない。
他の記事にもあるようにaccess.line.meにリダイレクトされ続けるループに落ちいる。

(参考)処理の内容

Reactにて実装
ホームディレクトリ"/"にて linktoken を取得
→"/login"に遷移して自社サービスにログインし nonceを取得
→アカウント連携URLへリダイレクトさせる

解決策

結論はLIFFブラウザで開くのではなく、外部ブラウザで開くように遷移させたら上手くいった。

改善前

window.location.href = "https://access.line.me/dialog/bot/accountLink?linkToken="+ encodeURIComponent(linktoken) +"&nonce="+ encodeURIComponent(nonce);

改善後

// login.jsx
liff.openWindow({
    url:"https://access.line.me/dialog/bot/accountLink?linkToken="+ encodeURIComponent(linktoken) + "&nonce=" + encodeURIComponent(nonce),
    external: true,
 });

所感

クエリパラメータでも似たような事象になっている人がいた。
LIFFは情報量が少ないので困った。なかなかLINE DCのコミュニティも活発ではないので、少しでも役に立てば幸いです。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0