XF 2.0 Add Connected Account

I added, but then XF:provider\Yahoo.
MMO\ExternalAccounts\ConnectedAccount:Provider\DeviantArt
Create phrase and there is no result
 
Last edited:
Well, moved the file to the engine and changed class to XF:Provider\DeviantArt and XF:Provider\Vkontakte.
Works, I specify the class does not work
 
Last edited:
MMO\ExternalAccounts:Provider\DeviantArt
MMO\ExternalAccounts:Provider\Vkontakte
 
MMO\ExternalAccounts:Provider\DeviantArt

No reason why that shouldn't work. The above assumes that your full class name is MMO\ExternalAccounts\ConnectedAccount\Provider\DeviantArt meaning that you have a file named DeviantArt.php in src/addons/MMO/ExternalAccounts/ConnectedAccount/Provider and it assumes your add-on ID is MMO/ExternalAccounts.
 
You need to also implement a ProviderData class and that has a required method to implement to fetch the provider key from the provider's end point.

This will be whatever unique key is returned by the provider which is then used to authenticate against in the future.
 
in DeviantArt.php:
PHP:
public function getProviderDataClass()
    {
        return 'MMO\\ExternalAccounts:ProviderData\\' . $this->getOAuthServiceName();
    }
Created The File. And file contain:
PHP:
public function getProviderKey()
    {
        return $this->requestFromEndpoint('uid');
    }
 
Sounds ok, in theory.

If it isn't working you'll just need to try and ascertain if the method is being called, that it is returning the expected data etc.
 
If I start doing a check in the control panel, then everything is fine, I start to make an association with an external account, I get an error. It does not matter what value is in the function: public function getProviderKey(). When debugging, the browser console returns a json with an error.
Debuggind getProviderKey and the null
 
Last edited:
@Chris D, The error is still the same, I decided to take a break from the implementation of Vkontakte. Implemented DeviantArt, everything works and connects without problems and also when testing outputs a name and avatar.
Снимок.webp
The key is also transmitted
Снимок1.webp
PHP:
public function getProviderKey()
{
    return $this->requestFromEndpoint('userid');
}
And result:
Снимок.webp
When you bind vkontakte get:
Снимок.webp
https://vk.com/pages?oid=-17680044&p=getProfiles
https://vk.com/dev/auth_sites
state is not passed, but in XF 1 it was transmitted and possibly because of this.
XF1:
https://oauth.vk.com/authorize?client_id=my_client_id&scope=&state=0f9f0b3d468246f782f43cd15820853b&redirect_uri=https%3A%2F%2Fmy-site.ru%2Fregister%2Fvk%3Fassoc%3D1&response_type=code
XF2:
https://oauth.vk.com/authorize?type=web_server&client_id=my_client_id&redirect_uri=https%3A%2F%2Fmy-site.su%2Fconnected_account.php&response_type=code&scope=
To create a state, in XF1 it was like this:
$state = md5(uniqid('xf', true));
 
Last edited:
I don't think you should be returning a hardcoded string in getProviderKey... I think you're supposed to return the unique ID for the user given by the remote provider?

Liam
 
What do you have returned by the getDefaultEndpoint() method? As far as I can tell from the documentation the correct param to go for is uid rather than userid.
 
Back
Top Bottom