I’m trying to create a new auth client for Mailchimp. Here’s my configuration in common/config:
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'mailchimp' => [
'class' => 'common\authclient\Mailchimp',
'clientId' => '12345679',
'clientSecret' => 'abcdefghijklmni...',
],
],
],
And here’s my client class (so far):
<?php
namespace common\authclient;
use yii\authclient\OAuth2;
class Mailchimp extends OAuth2
{
/**
* {@inheritdoc}
*/
public $authUrl = 'https://login.mailchimp.com/oauth2/authorize';
/**
* {@inheritdoc}
*/
public $tokenUrl = 'https://login.mailchimp.com/oauth2/token';
/**
* {@inheritdoc}
*/
public $apiBaseUrl = 'https://login.mailchimp.com/oauth2/';
/**
* @inheritdoc
*/
protected function initUserAttributes()
{
return $this->api('userinfo', 'GET');
}
/**
* {@inheritdoc}
*/
protected function defaultName()
{
return 'MailChimp';
}
/**
* {@inheritdoc}
*/
protected function defaultTitle()
{
return 'MailChimp';
}
}
When I do
use common\authclient\Mailchimp;
$oauthClient = new Mailchimp(); var_dump($oathClient);
I get this:
object(common\authclient\Mailchimp)#149 (23) {
["authUrl"]=>
string(44) "https://login.mailchimp.com/oauth2/authorize"
["tokenUrl"]=>
string(40) "https://login.mailchimp.com/oauth2/token"
["apiBaseUrl"]=>
string(35) "https://login.mailchimp.com/oauth2/"
["version"]=>
string(3) "2.0"
["clientId"]=>
NULL
["clientSecret"]=>
NULL
Why are the id and secret properties empty?