## 事象
[[Slackアプリ]]の `OAuth & Permissions > Redirect URLs` に2つの[[リダイレクトURI]]が登録されている状態で、[[oauth.v2.access (Slack Web API)|oauth.v2.access]] を利用すると以下の結果が返却される。
```json
{"ok":false,"error":"bad_redirect_uri"}
```
なお、直前に[[認可リクエスト (OAuth 2.0)|認可リクエスト]]で指定した[[リダイレクトURI]]では2つ目に登録された値を指定し、[[認可コード (OAuth 2.0)|認可コード]]の取得は正常に完了していた。
- `client_id` と `client_secret` は[[Authorizationヘッダー]]に[[Basic認証]]として指定
- `code` は `application/json` で `{"code": "..."}` を指定
## 原因
[[oauth.v2.access (Slack Web API)|oauth.v2.access]]に`redirect_uri`が指定されていないから。
`redirect_uri` はOPTIONALだが、[[認可リクエスト (OAuth 2.0)|認可リクエスト]]で `redirect_uri` を指定した場合は必須らしい。
> A potential gotcha: while `redirect_uri` is optional, it is **required** if your app passed it as a parameter to `oauth/authorization` in the first step of the OAuth flow.
>
> *[oauth.v2.access method | Slack Developer Docs](https://docs.slack.dev/reference/methods/oauth.v2.access/#usage-info) *
なお、**登録されている `Redirect URLs` が1つだけの場合は、`redirect_uri` を指定しなくても動作するようになっている**ため、この仕様には気づきにくい。
## 解決方法
[[oauth.v2.access (Slack Web API)|oauth.v2.access]]に `redirect_uri` を指定する。
## 参考
- [Multiple redirect url not working in slack sso](https://stackoverflow.com/questions/65828619/multiple-redirect-url-not-working-in-slack-sso/69659251#69659251)