Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
The "Salesforce auth token request version" setting in the setting form has the following definition:
// src/Form/MarketingCloudSettings.php
$form['request_token_version'] = [
'#type' => 'select',
'#title' => $this->t('Salesforce auth token request version'),
'#description' => $this->t('The newer version of token request requires different parameters to the legacy v1.'),
'#options' => [
'v1',
'v2',
],
'#default_value' => $config->get('request_token_version'),
];
Where the options have keys "0" for "v1" and "1" for "v2"
But the module checks for "v1" and "v2" keys during the Token request:
private function requestToken($clientId, $clientSecret) {
try {
\Drupal::logger(__METHOD__)->info('%message', ['%message' => 'Fetching a new token.']);
$url = $this->config
->get('request_token_url');
$requestVersion = $this->config
->get('request_token_version');
switch ($requestVersion) {
case 'v1':
$url .= '/v1/requestToken';
$formParams = [
'clientId' => $clientId,
'clientSecret' => $clientSecret,
];
$accessToken = 'accessToken';
break;
case 'v2':
default:
$url .= '/v2/token';
$formParams = [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'grant_type' => 'client_credentials',
];
$accessToken = 'access_token';
break;
}
So in the result default case ("v2") is always using.
Proposed resolution
Replace values "0" and "1" by values "v1" and "v2" on the settings form and update existing configs.
Comment | File | Size | Author |
---|---|---|---|
#2 | marketing_cloud-request_token_version_fix-3164764-2.patch | 1.37 KB | Oleksiy |
Comments
Comment #2
OleksiyComment #3
andypostLooks good to go
Comment #5
john_a CreditAttribution: john_a as a volunteer commentedMany thanks for taking the time to create and test this patch.
This patch has been applied to 8.x-1.x and 8.x-1.x-dev and will be included in the next release.
Comment #6
john_a CreditAttribution: john_a as a volunteer commented