title: get end user tokens for eBay restful in Python
body: <p>currently I am using eBay Trading API with Python. Thanks to: <a href="https://github.com/timotheus/ebaysdk-python" rel="nofollow noreferrer">https://github.com/timotheus/ebaysdk-python</a></p>
  
  <p>I used <a href="https://github.com/luke-dixon/django-ebay-accounts" rel="nofollow noreferrer">https://github.com/luke-dixon/django-ebay-accounts</a> to get tokens for user.</p>
  
  <p>Now, I would like to use Restful API (<a href="https://developer.ebay.com/docs#Acc" rel="nofollow noreferrer">https://developer.ebay.com/docs#Acc</a>). I don't think I can use tokens I have already. So, I managed thanks to <a href="https://stackoverflow.com/questions/44046855/getting-an-ebay-oauth-token">Getting an Ebay OAuth Token</a> get one. But I think I missing something, because during the process I cannot include info for user (name/password), so, for example <code>https://api.ebay.com/sell/fulfillment/v1/order?limit=10</code> returns: </p>
  
  <pre><code>{
    "errors": [{
      "errorId": 1100,
      "domain": "ACCESS",
      "category": "REQUEST",
      "message": "Access denied",
      "longMessage": "Insufficient permissions to fulfill the request."
    }]
  }
  </code></pre>
  
  <p>Any idea how can I get a token for the user?</p>
  
  <p>Just snippet of code to make things more clear:</p>
  
  <pre><code>AppSettings = {
              'app_id': EBAY_PRODUCTION_APPID,
              'app_secret': EBAY_PRODUCTION_CERTID,
              'dev_id': EBAY_PRODUCTION_DEVID, 
              'ruName': EBAY_PRODUCTION_RU_NAME 
          }
  authHeaderData = AppSettings['app_id'] + ':' + AppSettings['app_secret']
          encodedAuthHeader = base64.b64encode(authHeaderData.encode())
  
          headers = {
              "Content-Type": "application/x-www-form-urlencoded",
              "Authorization": "Basic ".encode() + encodedAuthHeader
          }
  body = {
              "grant_type": "client_credentials",
              "redirect_uri": settings.EBAY_PRODUCTION_RU_NAME,
              "scope": "https://api.ebay.com/oauth/api_scope"
          }
  
          data = urllib.parse.urlencode(body)
  
          tokenURL = "https://api.ebay.com/identity/v1/oauth2/token"
  
          response = requests.post(tokenURL, headers=headers, data=body)
          authDict = response.json()
  </code></pre>
  
  <p>So the request to run I need is:</p>
  
  <pre><code>r = requests.get("https://api.ebay.com/sell/fulfillment/v1/order?limit=10",
                           headers={"Authorization": "{}".format(authDict['access_token']),
                                    "Content-Type": "application/json",
                                    "X-EBAY-C-MARKETPLACE-ID": "EBAY_UK",
                                    "Accept": "application/json"
                                    })
  </code></pre>