How To Associate My Api Application With My Existing Shapeways Account

Discussion in 'Shapeways API' started by yannb, Feb 28, 2019.

  1. yannb
    yannb Member
    I have been using shapeways for a while now through the web front end, which means I have an account that I use to sign in to the site. I just created an application through the api getting started page: https://developers.shapeways.com/quick-start. I now have a clientId and secret key as expected. However they are not tied to my site account. Is there anyway to link them?

    thanks
     
  2. stonysmith
    stonysmith Well-Known Member Moderator
    When you created the clientid, it was associated with the account that you were logged in with.
    As you click "Add App", you should see your avatar up in the right hand top corner of the page.
     
  3. yannb
    yannb Member
    Thanks for the response, it turns out that it is tied to my account as I can get my models, however, when I try and get a list of all my orders, I get the following response:
    {u'ordersInfo': None, u'nextActionSuggestions': [], u'ordersCount': {u'unknown': 0, u'placed': 0, u'shipped': 0, u'in_production': 0, u'cancelled': 0, u'total': 0}, u'result': u'success', u'ordersStatus': []}
    Which is incorrect, since I have put in a lot of orders and I have some pending orders.

    here is the code as per the instructions here: https://developers.shapeways.com/quick-start
    ```
    import requests
    url = 'https://api.shapeways.com/oauth2/token'
    client_id = 'my_client_id'
    client_secret = 'my_client_secret'

    post_data = {
    'grant_type': 'client_credentials'
    }

    response = requests.post(url=url, data=post_data, auth=(client_id,client_secret))
    access_token = response.json()['access_token']
    print("Access token: " + access_token)

    headers = {
    'Authorization': 'Bearer ' + access_token
    }
    api_url = 'https://api.shapeways.com/orders/v1'
    response = requests.get(url=api_url +'?', headers=headers)
    print(response.json())

    api_url = 'https://api.shapeways.com/models/v1'
    response = requests.get(url=api_url +'?', headers=headers)
    print(response.json())

    ```
     
  4. PeregrineStudios
    PeregrineStudios Well-Known Member