fix auth mailchimp
@@ -126,6 +126,9 @@ impl Company {
if let Some(mut t) = APIToken::get_from_db(db, self.id, "mailchimp".to_string()) {
// Initialize the MailChimp client.
let mut mailchimp = MailChimp::new_from_env(t.access_token, t.refresh_token.to_string(), t.endpoint.to_string());
+ // MailChimp does not give you a refresh token so we should never refresh.
+ // https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/
+ if !t.refresh_token.is_empty() {
let nt = mailchimp.refresh_access_token().await.unwrap();
t.access_token = nt.access_token.to_string();
t.expires_in = nt.expires_in as i32;
@@ -139,6 +142,7 @@ impl Company {
t.expand();
// Update the token in the database.
t.update(&db).await;
+ }
return mailchimp;
}
