Twitter APIで403エラーが急に発生した時の対応メモ

TL;DR
- 急に403エラー
- X Developer Portalで エラーの出てるAppをProjectのAppsへ紐づける
運用しているTwitterのBotで下記のエラーが急に発生。
ツイートが全くできなくなったので、対応する。
エラーが発生しました。
Twitter.post
Twitter API エラー: 403
{"client_id":"1234","detail":"When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.","registration_url":"https://developer.twitter.com/en/docs/projects/overview","title":"Client Forbidden","required_enrollment":"Appropriate Level of API Access","reason":"client-not-enrolled","type":"https://api.twitter.com/2/problems/client-forbidden"%7D

メッセージを翻訳すると下記。
「Twitter API v2エンドポイントへのリクエストを認証する際は、プロジェクトにアタッチされているTwitter開発者アプリのキーとトークンを使用する必要があります。
プロジェクトは開発者ポータルから作成できます。」
元々投稿できており、キーやトークンに問題はないはず。
プロジェクトにアタッチされなくなった?
とりあえずX Developer Portalにアクセスしてみる。
該当するTwitterのプロジェクトがSTANDALONE APPSのBot1に該当することになっていた。
(実装したのが数年以上前なので覚えてないが、こんな項目あったっけ?)

ProjectにAppをリンクする
Projectページの下部のAppsに「Add App」ボタンがあるので、ここからリンクする。
Add an exisiting を選択。
該当するアプリを選択。
これでアプリにプロジェクトを追加できたはず。

無事ツイートされたのでClose

2023年の6月に勝手にStandalone Appになっているツイートが多い。
今回もそれ・・・?