LoginSignup
2
3

More than 1 year has passed since last update.

【Slack】Bot User OAuth Tokenの取得方法

Last updated at Posted at 2022-09-08

目的

GAS(Google App Script)でSlack APIを利用するにはSlackアプリAPIの Token が必要です。
Tokenを発行する手順を案内します。

Slackアプリの作成

1.Slackにログインする
https://slack.com/intl/ja-jp/get-started#/createnew
slack0サインインする.png

2.Slack APIのページにアクセスします。
https://api.Slack.com/apps
SlackアプリのAPI利用手順1.png

3.右上の、「Create an App」 をクリックします。
※すでに作成済みの場合は、右上に表示される「Create New App」をクリックします)
SlackアプリのAPI利用手順3 .png

4.[From scratch]をクリックします。
SlackアプリのAPI利用手順3-2 .png

5.「アプリ名 (App Name)」を入力し「利用するSlack
ワークスペース名(Development Slack Workspace)」を選択し、「Create App」ボタンをクリックします。
アプリ名(App Name):何でもよい
ワークスペース名(Development Slack Workspace):ワークスペース名 

slack1-2.png

Slack APIのスコープ&パーミッション設定

Slackアプリの操作ができる権限を追加します。
操作する内容によって権限が変わります。

1.SlackアプリのSettingメニューにある「OAuth & Permissons」を選択します
image.png

2.[Scopes]メニュー配下の[User Tocken Scopes] から「Add an OAuth Scope」ボタンをクリックします。
Slackボットで必要なとなる権限を追加します
oauth-scope0.png
oauth-scope2.png

今回追加する権限
「channels:write」
「files:read」
「groups:history」
「groups:read」
「groups:write」
「im:history」
「im:read」
「im:write」
「mpim:history」
「mpim:read」
「mpim:write」
「usergroups:read」
「channels:read」
「channels:history」
「users:read」
 

Slack APIのUSER用トークンを発行

※すべて「OAuth & Permissons」での作業

1.画面を上にスクロールし「Install to Workspace」をクリックする
slack4-2.png

2.認証画面が表示されるので「許可する」をクリックする
slackapp9.png

3.User OAuth Token に表示されたトークンをコピーする
token.png

2
3
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
2
3