I've added a throw $e in the catch block in AbstractProviderData::requestFromEndpoint and when attempting to connect an account, I now see the following error:
Code:
XF\ConnectedAccount\Http\HttpResponseException: Failed to request resource. HTTP Code: 403 in src/XF/ConnectedAccount/Http/Client.php at line 67
XF\ConnectedAccount\Http\Client->retrieveResponse() in src/vendor/lusitanian/oauth/src/OAuth/OAuth1/Service/AbstractService.php at line 141
OAuth\OAuth1\Service\AbstractService->request() in src/XF/ConnectedAccount/ProviderData/AbstractProviderData.php at line 100
XF\ConnectedAccount\ProviderData\AbstractProviderData->requestFromEndpoint() in src/XF/ConnectedAccount/ProviderData/Twitter.php at line 14
XF\ConnectedAccount\ProviderData\Twitter->getProviderKey() in src/XF/Admin/Controller/ConnectedAccount.php at line 95
XF\Admin\Controller\ConnectedAccount->actionPerformTest() in src/XF/Mvc/Dispatcher.php at line 352
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 259
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2351
XF\App->run() in src/XF.php at line 517
XF::runApp() in admin.php at line 13
I regenerated the Consumer API combo in my Twitter developer account and re-entered this into XenForo's corresponding config for Twitter. However, the result is the same.
It looks like XenForo is sending a separate request to Twitter to get the provider_key (id_str), when Twitter already sent the user's ID number to connected_account.php and it exists in the storageState.
When looking at ConnectedAccount\ProviderData\Twitter, I suspect the problem is that XenForo is trying to access an endpoint that does not exist in the new version of the Twitter API (v2), which is the only obvious option on Twitter's developer dashboard. If XenForo requires API v1, it should say that in the manual and explain how to use it instead of v2. After a lot of research, it looks like you need to upgrade your dashboard to "Elevated" to even see API v1.1 anymore.
After upgrading my dashboard to "Elevated" (the approval process took about 5 seconds), the Twitter provider Test is successful and I have been able to connect an account.
So it seems, as suspected, this is just an issue with the XenForo manual, where a number of critical steps are missing from the manual. However, as noted above, XenForo does make a request to Twitter's API for information it has already received.