title: Submitting uploaded Imgur image to gallery
body: <p>This is a follow up question to: 
  <a href="https://stackoverflow.com/questions/16244183/uploading-a-file-to-imgur-via-python">uploading a file to imgur via python</a></p>
  
  <p>I just uploaded an image to Imgur, but I've noticed it isn't public for view. At their API website they say that after its uploaded if you want it to be public you should submit it to the gallery.</p>
  
  <p>I coded a small app that could do this with one image, but I'm not sure if it's not working because I am not making the request right, or because I might be missing using the Oauth2 module, that so far I haven't required using it (I'm just uploading images but I don't have a need to see what other users are uploading with my app).</p>
  
  <pre><code>import base64
  import json
  import requests
  
  from base64 import b64encode
  
  client_id = '6a06c6bb8360e78'
  
  headers = {"Authorization": "Client-ID 6a06c6bb8360e78"}
  
  api_key = '6a06c6bb8360e78'
  
  url = "https://api.imgur.com/3/upload.json"
  
  j1 = requests.post(
      url, 
      headers = headers,
      data = {
          'key': api_key, 
          'image': b64encode(open('1.jpg', 'rb').read()),
          'type': 'base64',
          'name': '1.jpg',
          'title': 'Picture no. 1'
      }
  )
  
  
  data=json.loads(j1.text)['data']
  data_id=data['id']
  
  data_id_str=data_id.encode('ascii','ignore')
  
  # Now I try to push the iamge to the gallery with id data:
  
  url_gallery = "https://api.imgur.com/3/gallery/image/{id}.json"
  
  r2 = requests.post(url_gallery, headers=headers, data={'title': 'First image', 'terms': '1', 'id': data_id_str})
  </code></pre>
  
  <p>The answer I get after doing: 
      r2.text 
  is a 403 error:</p>
  
  <pre><code>u'{"data":{"error":"Unauthorized",
  "request":"\\/3\\/gallery\\/image\\/{id}.json",
  "parameters":"terms = 1, id = 1jhIc2R, title = First
  image","method":"POST"},"success":false,"status":403}'
  </code></pre>
  
  <p>This is the Imgur API link for submitting images, I'm not sure where I did wrong: <a href="https://api.imgur.com/endpoints/gallery#to-gallery" rel="nofollow noreferrer">https://api.imgur.com/endpoints/gallery#to-gallery</a></p>