1
1

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.

Slack APIのusers.lookupByEmailでinvalid_authが出る場合の対処法

Last updated at Posted at 2023-08-23

前提

Slack Appのインストールは済んでいる前提です

現象

{
    "ok": false,
    "error": "invalid_auth"
}

が返却される

対処法

①OAuthのスコープにusers:read.emailを追加
・NGの例:users:read

②トークンを渡すやり方を以下にする
・GETメソッドならAuthorization headerで指定
・POSTメソッドならボディ部で指定
・NGの例:https://slack.com/api/users.lookupByEmail?email=[メールアドレス]&token=[取得したトークン]
でリクエストを投げている

つまづきポイント

users.lookupByEmailの古い仕様だと以下になっていたので、↑の①、②の対応としてください
・OAuthのスコープがusers:readでOKになっていた
・APIの叩き方が以下だった
https://slack.com/api/users.lookupByEmail?email=[メールアドレス]&token=[取得したトークン]

参考ドキュメント

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?