Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API key not retrieving properly from setting #93

Open
martinh-pw opened this issue May 29, 2020 · 0 comments
Open

API key not retrieving properly from setting #93

martinh-pw opened this issue May 29, 2020 · 0 comments

Comments

@martinh-pw
Copy link
Contributor

Hi there, we've had a really strange issue that I don't know the root cause for but I think is worth documenting here in case someone else can understand it better, or if this helps anyone else in the future.

The behavior we were seeing was that the "send test email" worked fine but most civimail would come back as bounced. These emails would not show up anywhere in our sparkpost account. Civi/curl would report this as: Sparkpost error: HTTP return code 503, Sparkpost error code (Unable to contact authorization service.: ).

What we eventually found was that the API key was not included properly in the request header. This call to get the key from the setting was returning garbage (sometimes!): CRM_Sparkpost::getSetting('sparkpost_apiKey'); Replacing this with just directly adding the API key as a string in the code resolved all our issues.

I don't know what about our setup would have caused this. One possible improvement could be to check specifically for a 503 return with some debug information around this condition (other return codes are already included in this way). Or, maybe some checking on the API key in the header to check for a certain length or other validation.

Versions: Civi 5.22.1, Drupal 7.69, sparkpost 1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant