title: CloudFlare (Memberful) post requests from Java produce a 403 error
body: <p>I'm trying to authenticate users using Memberful from a Spring-Boot application. Per the <a href="https://memberful.com/help/integrate/advanced/oauth/#authorization-code-grant" rel="nofollow noreferrer">Memberful documentation</a>, the process is as follows:</p>
  
  <ol>
  <li>User logs in at the memberful URL (<code>https://YOURSITE.memberful.com/oauth?client_id=APPLICATION_IDENTIFIER&amp;response_type=code</code>)</li>
  <li>User is redirected to my front end (Vue) with a code in the URL provided by Memberful.</li>
  <li>The code is passed to my back end server.</li>
  <li>Back end server sends a post request using <code>RestTemplate.postForObject(...)</code> from Spring to <code>https://YOURSITE.memberful.com/oauth/token</code> with all required parameters (See snippet below).</li>
  </ol>
  
  <p>At this point an access token payload is expected, but instead a 403 Error is returned.  </p>
  
  <p>Here's the full method:</p>
  
  <pre><code>import org.springframework.http.*;
  import org.springframework.util.MultiValueMap;
  
  ...
  
  
  private JSONObject getMemberfulAccessToken(String strCode){
          String strTargetURL = "https://" + memberfulSubDomain + ".memberful.com/oauth/token";
  
  
          HttpHeaders headers = new HttpHeaders();
          headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
  
          MultiValueMap&lt;String, String&gt; parameters = new LinkedMultiValueMap&lt;&gt;();
  
          parameters.add("client_id", memberfulApplicationIdentifier);
          parameters.add("client_secret", memberfulClientSecret);
          parameters.add("grant_type", "authorization_code");
          parameters.add("code", strCode);
  
          HttpEntity&lt;MultiValueMap&lt;String, String&gt;&gt; entity = new HttpEntity&lt;&gt;(parameters, headers);
  
          String strAccessToken = restTemplate.postForObject(strTargetURL, entity, String.class);
  
          return new JSONObject(strAccessToken);
      } 
  </code></pre>
  
  <p>And here's the response:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;!--[if lt IE 7]&gt; &lt;html class="no-js ie6 oldie" lang="en-US"&gt; &lt;![endif]--&gt;
  &lt;!--[if IE 7]&gt;    &lt;html class="no-js ie7 oldie" lang="en-US"&gt; &lt;![endif]--&gt;
  &lt;!--[if IE 8]&gt;    &lt;html class="no-js ie8 oldie" lang="en-US"&gt; &lt;![endif]--&gt;
  &lt;!--[if gt IE 8]&gt;&lt;!--&gt; &lt;html class="no-js" lang="en-US"&gt; &lt;!--&lt;![endif]--&gt;
  &lt;head&gt;
  &lt;title&gt;Access denied | [My Site].memberful.com used Cloudflare to restrict access&lt;/title&gt;
  &lt;meta charset="UTF-8" /&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /&gt;
  &lt;meta name="robots" content="noindex, nofollow" /&gt;
  &lt;meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" /&gt;
  &lt;link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" /&gt;
  &lt;!--[if lt IE 9]&gt;&lt;link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /&gt;&lt;![endif]--&gt;
  &lt;style type="text/css"&gt;body{margin:0;padding:0}&lt;/style&gt;
  
  
  &lt;!--[if gte IE 10]&gt;&lt;!--&gt;&lt;script type="text/javascript" src="/cdn-cgi/scripts/zepto.min.js"&gt;&lt;/script&gt;&lt;!--&lt;![endif]--&gt;
  &lt;!--[if gte IE 10]&gt;&lt;!--&gt;&lt;script type="text/javascript" src="/cdn-cgi/scripts/cf.common.js"&gt;&lt;/script&gt;&lt;!--&lt;![endif]--&gt;
  
  
  
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="cf-wrapper"&gt;
      &lt;div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies"&gt;Please enable cookies.&lt;/div&gt;
      &lt;div id="cf-error-details" class="cf-error-details-wrapper"&gt;
        &lt;div class="cf-wrapper cf-header cf-error-overview"&gt;
          &lt;h1&gt;
            &lt;span class="cf-error-type" data-translate="error"&gt;Error&lt;/span&gt;
            &lt;span class="cf-error-code"&gt;1010&lt;/span&gt;
            &lt;small class="heading-ray-id"&gt;Ray ID: 515be6c26b80c514 &amp;bull; 2019-09-13 17:39:35 UTC&lt;/small&gt;
          &lt;/h1&gt;
          &lt;h2 class="cf-subheadline"&gt;Access denied&lt;/h2&gt;
        &lt;/div&gt;&lt;!-- /.header --&gt;
  
        &lt;section&gt;&lt;/section&gt;&lt;!-- spacer --&gt;
  
        &lt;div class="cf-section cf-wrapper"&gt;
          &lt;div class="cf-columns two"&gt;
            &lt;div class="cf-column"&gt;
              &lt;h2 data-translate="what_happened"&gt;What happened?&lt;/h2&gt;
              &lt;p&gt;The owner of this website ([My Site].memberful.com) has banned your access based on your browser's signature (515be6c26b80c514-ua21).&lt;/p&gt;
            &lt;/div&gt;
  
  
          &lt;/div&gt;
        &lt;/div&gt;&lt;!-- /.section --&gt;
  
        &lt;div class="cf-error-footer cf-wrapper"&gt;
    &lt;p&gt;
      &lt;span class="cf-footer-item"&gt;Cloudflare Ray ID: &lt;strong&gt;515be6c26b80c514&lt;/strong&gt;&lt;/span&gt;
      &lt;span class="cf-footer-separator"&gt;&amp;bull;&lt;/span&gt;
      &lt;span class="cf-footer-item"&gt;&lt;span&gt;Your IP&lt;/span&gt;: 207.200.220.146&lt;/span&gt;
      &lt;span class="cf-footer-separator"&gt;&amp;bull;&lt;/span&gt;
      &lt;span class="cf-footer-item"&gt;&lt;span&gt;Performance &amp;amp; security by&lt;/span&gt; &lt;a href="https://www.cloudflare.com/5xx-error-landing?utm_source=error_footer" id="brand_link" target="_blank"&gt;Cloudflare&lt;/a&gt;&lt;/span&gt;
  
    &lt;/p&gt;
  &lt;/div&gt;&lt;!-- /.error-footer --&gt;
  
  
      &lt;/div&gt;&lt;!-- /#cf-error-details --&gt;
    &lt;/div&gt;&lt;!-- /#cf-wrapper --&gt;
  
    &lt;script type="text/javascript"&gt;
    window._cf_translation = {};
  
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>