You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Node.js中使用Mailchimp API OAuth2时,无法完成授权码换访问令牌

Troubleshooting Mailchimp OAuth2 Token Exchange (Step 4 Failure)

I’ve run into the exact same frustrating issue with Mailchimp’s OAuth2 token exchange step before—when you follow the docs to the letter and it still won’t work! Let’s break down the most common fixes that got me past this roadblock:

Common Issues & Fixes

  • Fix the & in your curl command
    The official docs sometimes use HTML-encoded & in the data string, but curl expects raw & to separate parameters. Replace all instances of & with just & in your --data payload—this is a super easy oversight that breaks the request.

  • Double-check your redirect URI (critical!)
    This is the #1 culprit for token exchange failures:

    • The redirect_uri in your curl request must be fully URL-encoded (use a standard URL encoder if you’re not sure about the correct format).
    • It must match exactly what you registered in your Mailchimp Developer Account—including trailing slashes, capitalization, and any query parameters. Even a tiny mismatch (like missing a slash) will get your request rejected.
  • Ensure your authorization code is valid
    Authorization codes are single-use and expire quickly (around 10 minutes). If you’ve already tried using that code once, you’ll need to go back through the full authorization flow to grab a fresh one.

  • Verify Client ID/Secret accuracy
    It’s shockingly easy to accidentally copy extra spaces or miss a character when grabbing these from the Mailchimp dashboard. Double-check that both client_id and client_secret match exactly what’s listed in your app settings—no typos allowed!

  • Add the Content-Type header explicitly
    While curl usually sets this automatically, some environments need a nudge. Try adding the Content-Type header to your request to ensure the payload is interpreted correctly:

    curl --request POST \
      --url https://login.mailchimp.com/oauth2/token \
      --header "Content-Type: application/x-www-form-urlencoded" \
      --data "grant_type=authorization_code&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&redirect_uri=YOUR_ENCODED_REDIRECT_URI&code=YOUR_AUTHORIZATION_CODE"
    
  • Check for network/proxy blockages
    If you’re running this from a server in a region with restricted access, make sure login.mailchimp.com is reachable. Test with a direct curl request without proxies to rule out connectivity issues.

If none of these work, share the exact error response you’re getting (e.g., invalid_grant, redirect_uri_mismatch)—that’ll help narrow down the problem even faster!

内容的提问来源于stack exchange,提问作者Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:32:40