SlackをAuth0に接続する
1
Slackの設定
- Slack Developerアカウントにサインアップします。
- まだ作成していない場合は、Slack Appを作成します。From scratch オプションを選択し、名前を付けてワークスペースを選択します。
- アプリが作成されたら、Client IDとClient Secretをコピーします。
- 左側のナビゲーションにあるOAuth & Permissionsセクションで、
以下の操作を行います。
- OAuth TokensでToken Rotationを選択してオプトインし、アプリが リフレッシュトークンに対応するようにします。
- Redirect URLsで、
https://YOUR_AUTH0_DOMAIN/login/callbackを新しいRedirect URLとして追加します。You can find the Auth0 domain in the Auth0 Dashboard.You can find this under Applications > [Your Application] > Settings > Basic Information > Domain.If you are using the custom domains feature, your Auth0 domain is the custom domain. You can find this under Branding > Custom Domains. - Scopesで、アプリの動作に必要なOAuthスコープを 追加します。
2
Auth0の設定
- Auth0 Dashboardで、 Authentication > Socialに移動します。Create Connectionを選択し、 Sign in with Slackを選択して、Continueを選択します。
- Generalで、作成したSlack OAuthアプリのClient IDとClient Secretを 入力します。
- Purposeで、Connected Accounts for Token Vaultをオンにします。これにより、 この接続で外部APIのアクセストークンを取得し、安全に保存できるようになります。詳しくは、Connected Accounts for Token Vaultを構成するを参照してください。
- Createを選択します。
- 保存したら、Applicationsタブに移動し、この接続を使用する アプリケーションを選択します。
アプリケーションでOrganizationsを使用している場合は、Connected Accounts フローを開始する前に、対象のOrganizationでユーザーを認証してください。この場合も、Token VaultはSlackの連携済みアカウントをユーザーのAuth0プロファイルに保存するため、Organizationの各メンバーがそれぞれ自分のSlackアカウントを認可することになります。
このガイドでは、Auth0 で Slack 接続をセットアップする手順を説明します。 このような接続を使用して、ユーザーに代わってアプリから第三者 API を呼び出す方法を一連の流れで示す例については、 ユーザーに代わって第三者 API を呼び出すクイックスタートをお読みください。
Token Vaultの設定例
Slack接続用にToken Vaultを設定するには、アプリケーションで次のコードスニペットを使用します。Next steps
- To learn how to configure applications to access Token Vault, read Configure Token Vault.
- If your application uses Organizations, authenticate the user with the target organization before initiating the Connected Accounts flow. Connected accounts remain linked to the individual user profile.
- To learn how to get an access token to make a tool call, complete the Call third-party APIs on user’s behalf Quickstart.