title: IBM Object Storage with Python
body: <p>I have some issue trying to save a file to IBM object storage via python. I copied the following credentials from the bluemix account (with details omitted below).</p>
  
  <pre><code>credentials = {
    "auth_url": "https://identity.open.softlayer.com",
    "project": &lt;my project&gt;,
    "projectId": &lt;my project id&gt;,
    "region": "dallas",
    "userId": &lt;user id&gt;,
    "username": &lt;user name&gt;,
    "password": &lt;password&gt;,
    "domainId": &lt;domain Id&gt;,
    "domainName": &lt;domain Name&gt;,
    "role": &lt;role&gt;
    }
  </code></pre>
  
  <p>And below is the python script that I have used trying to save a file to the container
      from io import StringIO
      import requests
      import json</p>
  
  <pre><code>url1 = ''.join(['https://identity.open.softlayer.com', '/v3/auth/tokens'])
  data = {'auth': {'identity': {'methods': ['password'],
          'password': {'user': {'name': credentials['username'],'domain': {'id': credentials['domainId']},
          'password': credentials['password']}}}}}
  headers1 = {'Content-Type': 'application/json'}
  resp1 = requests.post(url=url1, data=json.dumps(data), headers=headers1)
  resp1_body = resp1.json()
  for e1 in resp1_body['token']['catalog']:
      if(e1['type']=='object-store'):
          for e2 in e1['endpoints']:
                      if(e2['interface']=='public'and e2['region']=='dallas'):
                          url2 = ''.join([e2['url'],'/', container, '/', filename])
  s_subject_token = resp1.headers['x-subject-token']
  headers2 = {'X-Auth-Token': s_subject_token, 'accept': 'application/json'}
  print(url2)
  resp2 = requests.post(url=url2, data=filename, headers=headers2)
  print(resp2.text)
  return StringIO(resp2.text)
  
  filename = "sample.png"&lt;br&gt;
  post_object_storage_file("democontainer", filename)
  </code></pre>
  
  <p>I seems to get a token via resp1 and obtained url2. However, I get a 'Forbidden' response when i print resp2.text. I am the admin for that storage container so I don't see why I can't have access with this.</p>
  
  <p>I am new to the IBM object storage so any advice will be helpful.</p>
  
  <p>Thanks.</p>