7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【凡ミス】LINE botからユーザーへpostしようとした際の401エラー

Last updated at Posted at 2022-05-11

目次

  • 初めに
  • エラー内容
  • エラーの対処

1. 初めに

  • こちらの記事はLINE botからユーザへメッセージを送信しようとした際に、401エラーで弾かれた際のエラー対処記録になります。GAS環境で作成し、実行を押したらエラーが出ました。

2. エラー内容

エラーの内容は以下の通りです。

Exception: Request failed for https://api.line.me returned code 401. Truncated server response: {"message":"Authentication failed. Confirm that the access token in the authorization header is valid."} (use muteHttpExceptions option to examine full response)

要するに

アクセストークンが有効であることを確認しろ

だそうです。

もちろんこの手のエラー対処はたくさんネットに転がっていました。

  • ↓こちらの記事ではGASのアプリ公開範囲を[自分のみ]にしていたという結論で、[全員に公開]で解決していました。

  • 他にも、長期のアクセストークンではなく、短期のアクセストークン(?)を使うといけたとか・・?
    短期のアクセストークンなんて私のLINE Developerにはありませんでした。

  • あとはwebhook をon/offに何回かするといけたとかいう記事もありました。

3. エラーの対処

  • 結論から言うとめちゃくちゃ凡ミスでした。(てか普通に気づけるはずない)
    私はLINE Developersのサイトはデフォルトで英語でした。
    なので、safariの機能で日本語翻訳をしていると、Channel access tokenがなんと翻訳を挟んで変わってしまっていました。
    変わったChannel access tokenをコピペし、コードに貼り付けても応答がないのは当たり前ですよね。

極力翻訳機能は使わないようにしよう

と思った今日この頃でした^^

7
4
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
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?