title: Youtube API Invalid Grant and Required parameter is missing: grant_type
body: <p>I'm having trouble authenticating with the Youtube API via OAuth. It gives me this error: </p>
  
  <ul>
  <li>"error" : "invalid_grant" for <strong>CURL</strong></li>
  <li>"error" : "invalid_request",<br>
  "error_description" : "Required parameter is missing: grant_type" for <strong>GoLang</strong></li>
  </ul>
  
  <p>This is my CURL code:</p>
  
  <p><code>curl -i -X POST "https://accounts.google.com/o/oauth2/token" \
      -F 'code=CODE_FROM_MY_USER' \
      -F 'client_id=MY_CLIENT_ID' \
      -F 'client_secret=MY_CLIENT_SECRET' \
      -F 'redirect_uri=http://localhost:8080/platform/youtubeCallback.html' \
      -F 'grant_type=authorization_code'
  </code></p>
  
  <p>This is my Go code and has been verified to work for the Soundcloud API.</p>
  
  <pre><code>func Auth(code string) err {
      v := url.Values{}
      v.Set("code", code)
      v.Set("client_id", "MY_CLIENT_ID")
      v.Set("client_secret", "MY_CLIENT_SECRET")
      v.Set("redirect_uri", "http://localhost:8080/platform/youtubeCallback.html")
      v.Set("grant_type", "authorization_code")
  
      params := strings.NewReader(v.Encode())
  
      req, err := http.NewRequest("POST", "https://accounts.google.com/o/oauth2/token", params)
      if err != nil {
          return err
      }
      req.Header.Add("Accept", "application/json")
  
      resp, err := c.Client.Do(req)
      if err != nil || resp.StatusCode != 200 {
          return err
      }
  
      json.NewDecoder(resp.Body).Decode(&amp;c.Token)
  
      return nil
  }
  </code></pre>