Noob To Shapeways Api

Discussion in 'Shapeways API' started by seya1984, Sep 29, 2016.

  1. seya1984
    seya1984 Member
    I'm kind of desperate I've been trying for several days to make a simple model uploader to Shapeways (from a zip file) :
    I'm a newbie in web API's so the documentation
    is almost useless to me as it assumes a deep knowledge, please don't refer me back to them in a circular argument.

    In the web all I see are scattered partial snippets of code that also didn't help me to see a working code and learn from it.

    From those documentation the more familiar to me is python. I already have a simple "App" with the public key and the secret key
    the problem is how I move on from there.

    Could anybody share at least a working code of that functionality? from all attempts I do I never authenticate because I don't know what are the verify and the token and....

    [RANT ONT] Argh ...I feel like i need to go back to college to learn web dev, and then RestFul and then PHP and the python and then shapeways api order to do a simple uploader... I guess nuclear physics simulation is easier than this!
    So much complexity to do trivial tasks! OMG -get this, send to this ...that's it! it should be 3 lines of anyone's code! I guess web dev needs to justify their salaries adding complexity layers to everything and protocols, and frameworks, and redundancy.....[RANT OFF]

    Thanks in advancce
  2. seya1984
    seya1984 Member
    .....hello? is anybody home?
  3. stonysmith
    stonysmith Well-Known Member Moderator
  4. seya1984
    seya1984 Member
    Oh thank you!
    Is true, like optimization, security is the source of all evil :p
    I hope your code finally help me to understand this.

    I'm like a biologist that learn from living organism (working code) and not dead tissues (floating snippets of code)
    I will update you any progress!

  5. seya1984
    seya1984 Member
    Well, I'm trying and I always get an autentication error! the first part goes fine, retrieving the keys and then at the basic step of GetListOfModels it never connects and i did the steps correctly

    {u'reason': u'Authentication Error', u'result': u'failure', u'oauth_error_message': u'oauth_problem=signature_invalid&debug_sbs=GET&}

    is it my App? Ive done the steps recommended on the documentation and I have created it.
  6. seya1984
    seya1984 Member
    Yep, definitely nothing I do allow me to access the resources, I always get 401 response and that's frustrating...I set the keys correctly, I've tried with different browsers...nothing works
  7. seya1984
    seya1984 Member
    heres the error and i follow carefully all your steps, so what's missing?

    {u'reason': u'Authentication Error', u'result': u'failure', u'oauth_error_message': u'oauth_problem=parameter_absent&oauth_parameters_absent=oauth_consumer_key%26oauth_signature%26oauth_signature_method%26oauth_nonce%26oauth_timestamp%26oauth_token'}
  8. seya1984
    seya1984 Member
    i/m sure oauth is getting all of those keys...I haven't change your code, just using my own keys
  9. stonysmith
    stonysmith Well-Known Member Moderator
  10. seya1984
    seya1984 Member
    hmm... my answer is 401 , not 403.
    Here's a simple listing based on your code:

    import json
    import os
    from Shapeways import Shapeways
    import webbrowser
    from requests_oauthlib import OAuth1
    from Shapeways import Shapeways

    import AuthKeys
    #import GetKeys #executes the keys dance

    import requests
    from requests_oauthlib import OAuth1
    from urlparse import parse_qs

    client_key = AuthKeys.client_key
    client_secret = AuthKeys.client_secret

    oauth = OAuth1(client_key,client_secret=client_secret,resource_owner_key=AuthKeys.resource_owner_token,resource_owner_secret=AuthKeys.resource_owner_secret,verifier= AuthKeys.myPin)
    r = requests.get(url='', auth=oauth) #

    print r

    <Response [401]>