Can't connect Twitter account: Please enter a value for the required field 'provider_key'.

pegasus

Well-known member
Affected version
2.2.8
I've set up a new Twitter app via the instructions in the XenForo manual. The integration fails "Test provider". Since there is a years-long thread about that issue on here, I figured it might work by going to my XenForo user's Connected accounts page and trying it out.

The button takes me to Twitter, which goes through the motions and redirects me back. XenForo asks me for my password. When I click to "Associate", XenForo gives the following message: "Please enter a value for the required field 'provider_key'."

Either the XenForo manual is lacking or the integration needs to be updated for changes to the Twitter API. Since it works on xenforo.com, I'm thinking it's actually the former.
 
Did you setup the setting in ACP - Settings - Connected Accounts - Twitter

You see Consumer Secret and Consumer Key, both you get after creating an application on twitter. Did you use thiese credentials?
 
Yes, I set the Customer Key and Secret, per the manual. I've been snooping the response from Twitter to connected_account.php as well. And it is sending XenForo a token and the Twitter user_id and screen_name. So the credentials are valid and as far as Twitter knows it's working. But XenForo isn't taking the token and putting it into providerData->provider_key for some reason.
 
Last edited:
Hmm, unfortunately I don;t use twitter so doesn't dare to say either if this is a bug from Xenforo or Twitter. Hope you will get feedback soon :)
 
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.
 
Last edited:
Back
Top Bottom