title: Using `curl` to create a repo on GitHub.com with two-factor authentication
body: <p>I'm having problems using <code>curl</code> to create a repo on my GitHub.com account (no ssh).</p>
  
  <p>I have created a basic static local site using <a href="http://jekyllrb.com/" rel="nofollow noreferrer">Jekyll</a> which I want to push to the GitHub.com repo (I want to host the site on <code>&lt;username&gt;.github.io</code> and according to the instructions on GitHub pages the repo must have the same name as the folder containing the local site.</p>
  
  <p>I have two-factor authentication enabled for the GitHub login, so following <a href="https://stackoverflow.com/a/20598750/997225">this post</a> I am passing an OTP/token (generated on <a href="https://github.com/settings/applications" rel="nofollow noreferrer">Applications settings</a> in the request header using the  option <code>-H "X-GitHub-OTP":&lt;token&gt;</code>.  I can log in (this post previously raised an issue about the Github login not working, which was due to not closing the string <code>"X-GitHub-OTP"</code> properly), but now the login works but I now receive a response with a 400 code.  Here is the <code>curl</code> command I am used:</p>
  
  <pre><code>$username="&lt;username&gt;"
  $reponame="$username.github.io"
  $token="&lt;token&gt;"
  $apidom="https://api.github.com/user/repos/"
  $curl -u $username -H '{"X-GitHub-OTPOTP":$token}' -d '{"name":$reponame,"description":$repodesc}' $apidom
  </code></pre>
  
  <p>and the response message:</p>
  
  <pre><code>&lt;p&gt;&lt;strong&gt;We didn't receive a proper request from your browser.&lt;/strong&gt;&lt;/p&gt;
  &lt;p&gt;Sorry about that. Please try refreshing and contact us if the problem persists.&lt;/p&gt;
  &lt;div id="suggestions"&gt;
  &lt;a href="https://github.com/contact"&gt;Contact Support&lt;/a&gt; &amp;mdash;
  &lt;a href="https://status.github.com"&gt;GitHub Status&lt;/a&gt; &amp;mdash;
  &lt;a href="https://twitter.com/githubstatus"&gt;@githubstatus&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>