WebMail Pro 7 documentation

Adding custom external services and social networks

To create connector for particular social network or some other kind of external services which provides authentication via OAuth2, the following steps should be performed:

1. The connector you create should reside under plugins/external-services/connectors directory.

For example, let's assume we're creating connector for Dropbox. The path to primary file of the connector should be plugins/external-services/connectors/dropbox/index.php

You can download sample Dropbox connector using this link.

The core class of connector's code will look like:

class SocialAuthConnectorDropbox extends SocialAuthConnector
{
	
        // the list of features provided by this connector
        public static function GetSupportedScopes()
	{
		return array('auth', 'filestorage');
	}

	public static function Init($oTenant)
	{
		return true;
	}
}

The connector class should be called SocialAuthConnectorNamehere, where Namehere corresponds to connector's name, with the first uppercase character.

External service settings are retrieved as follows:

//		$sSocialName - external service name, e.g. 'dropbox'
		
		$oSocial = $oTenant->GetSocialByName($sSocialName);
		$bAllow = isset($oSocial) ? $oSocial->SocialAllow : false;
		
		if($bAllow)
		{
			$sId = $oSocial->SocialId;
			$sSecret = $oSocial->SocialSecret;
		}

Also, connector may provide HasApiKey method which enables ApiKey support:

public static function HasApiKey()
{
	return true;
}

If the method is not declared in the connector, it will return false.

Adding the connector ensures creating a button for it, and clicking the button will result in navigating to link of the following kind:

InstallationURL/?external-services=ServiceName

Connector can also have scope (feature name) by adding &scope=ScopeHere to the URL, where ScopeHere is set to login, storage or any other value defined by specific external service.

2. Update the list of connectors in data/settings/config.php file:

'plugins.external-services' => true,
'plugins.external-services.connectors' => array(
	'google',
	'facebook',
	'twitter',
	'dropbox'
),

Note that if plugins.external-services.connectors is not specified or holds empty array, all the available connectors found in connectors subdirectory of the plugin will be enabled.

3. Update Socials section in data/settings/settings.xml file with block of the following kind:

<Dropbox>
	<Allow>On</Allow>
	<Name>Dropbox</Name>
	<Id>Id</Id>
	<Secret>Secret</Secret>
</Dropbox>