Upload models to an existing Shapeways shop?

Discussion in 'Shapeways API' started by 78499_deleted, Sep 5, 2013.

  1. 78499_deleted
    78499_deleted Member
    I already have a shop on Shapeways, instead of creating a new app, I would prefer to experiment with the API using my existing shop? Is this possible? Or do I have to create a new app for this effort?

    If it is possible, how do I extract the consumer key and secret from my own account?

     
  2. stonysmith
    stonysmith Well-Known Member Moderator
    Please excuse me if I get any of this wrong.. I've only been studying this in detail for a short while now.

    The consumer key and consumer secret are not directly related to your Shapeways shop. (the shop itself does not have a key)

    You go to the API page, sign in with your current userid, and then "Create an APP". Each APP you create will have it's own key and secret. You could have one APP that uploads your own private models, you could have another APP where you allow the public to create/upload models.

    Later in the process, when your APP makes a request from the API, the system will ask you [or the user] if they want to allow your app to access their account. Your APP can't see their security information, but temporary access is granted to your APP to request prices in their currency, materials, etc, and/or upload models.
     
  3. 78499_deleted
    78499_deleted Member
    Thank you Stonysmith.

    After several hours of furrowed brows and quite a bit of swearing I was able to successfully acquire an access token and secret.

    Some things I realized:
    1) Since I logged in as myself on Shapeways, then registered for an App ID. The consumer key and consumer secret will be associated with my login and the things I upload using the php scripts will show up in my account. So this actually answers my original question. I was thinking that registering for an App ID would create a separate place that the model's would be uploaded which would complicate things. This is not the case and the App ID uploads to my Shapeways account.

    2) The sample php files provided in the Shapeways php-pecl directory are not actually websites I can plug into the browser bar but instead interactive command line php scripts which prompt the user for values. This is an important distinction. The php doesn't wait for the user to plug in the PIN value when I was running it from the browser, so I kept getting access errors.

    So to summarize my use of the php-pecl scripts:
    1) Login to Shapeways with your username and password.
    2) Create a new App (IE fill in all the required blanks) and then push the "Create App" button.
    3) The Shapeways Developers website will provide a consumer key and secret token. Plug these values into the "consumer_key.php" file.
    4) Run the Authorize-oauth1-pecl.php script using the php command line. On my mac this command looks like this:

    php -c <long_path_name_to_the_php_ini_file>/php.ini -f Authorize-oauth1-pecl.php

    4) The Authorize-oauth1-pecl.php will talk with the Shapeways servers using the consumer key and secret token and return a URL that the user is to cut and paste in the browser to get a PIN number.
    5) Take that pin number from the generated URL and plug it into the "Pin: " prompt from the Authorize-oauth1-pecl.php script
    6) With the correct PIN entered, the script will provide an access token and secret which the user can place in the "access_token.php" file for use with the other scripts in the php-pecl directory.


    I realize I'm being very verbose about this, but I'm writing this down to help others and so that I don't forget. These instructions also assume the user has successfully installed php, php-pecl and oauth modules. I might add these steps also required quite a bit of swearing.

    Thank you again.