カスタムOAuth アプリの作成
Follow the steps below to create a Twitter application and obtain the OAuth client credentials:
- Log in to https://developer.twitter.com/en/portal/projects-and-apps. If you have not done so already, sign up for a developer account.
- To access the Twitter API v1.1, you need to Apply for additional access within the developer portal. You can read more about this in the Twitter API documentation.
- Once you are on the Developer Portal, create a new Project. When you are done, you are redirected to create a new App. You can also go to the Project you just created and click Add App.
- Set a name for the application and Twitter displays your keys and tokens. You should save these values somewhere since you need them later for authentication.
- Go to the App settings. Under User authentication settings click Set up. Turn on the 'OAuth 1.0a' authentication.
- Select Read and write and Direct message from the available App permissions.
- Enter the website and other optional information to be displayed to users when they connect.
- Set the Callback URL:
- For desktop applications or headless machines, set the Callback URL to http://localhost:33333/.
- For web applications, set the Callback URL to the URL that you want users directed to after they have granted your application privileges.
If you intend to communicate with Twitter only as the currently authenticated user, then you can obtain the OAuthAccessToken and OAuthAccessTokenSecret directly from the Developer Portal on Twitter. Navigate to your application and go to Keys and tokens. There, click Generate on the Access Token and Secret option. You can then connect by setting the OAuthAccessToken and OAuthAccessTokenSecret connection properties.
Otherwise, if you need to generate access tokens for other user accounts besides the one you used to create the application on Twitter, use the consumer key and consumer secret.