has anyone used etsy-python to create listings recently?

1,001 views
Skip to first unread message

Miernik

unread,
Dec 11, 2011, 12:12:51 PM12/11/11
to Etsy API V2
Has anyone used this package:

https://github.com/mcfunley/etsy-python

to make createListing API calls to the Etsy API recently?

Can you give me an example how it is supposed to be used?

I've done the process with authorising the application and getting the
token described here: http://www.etsy.com/developers/documentation/getting_started/oauth
and it seemed fine, with all required permissions, and saved the token
key and token secret into config.py

When I try something like in test_v2.py in to source directory of etsy-
python, like this:

import oauth2 as oauth
from etsy import Etsy, EtsyEnvSandbox, EtsyEnvProduction
from etsy.oauth import EtsyOAuthClient
import config
etsy_env = EtsyEnvProduction()
oauth_client =
EtsyOAuthClient(oauth_consumer_key=config.oauth_consumer_key,
oauth_consumer_secret=config.oauth_consumer_secret, etsy_env=etsy_env)
oauth_client.token = oauth.Token(key=config.oauth_token_key,
secret=config.oauth_token_secret)
etsy_api = Etsy(etsy_oauth_client=oauth_client, etsy_env=etsy_env)
r1 = etsy_api.createListing(description='test description',
title='test title', price=25, shipping_template_id=7271435,
quantity=1)

all I get is:

ValueError: Could not decode response from Etsy as JSON: 'This method
requires authentication.'

SnakeO

unread,
Dec 11, 2011, 4:01:14 PM12/11/11
to Etsy API V2
Try removing the 'api_key' parameter that gets sent

Miernik

unread,
Dec 11, 2011, 5:41:57 PM12/11/11
to Etsy API V2
On Dec 11, 10:01 pm, SnakeO <jakech...@gmail.com> wrote:
> Try removing the 'api_key' parameter that gets sent

It seems that currently etsy-python does all requests with api_key, so
I
tried to hack it, and in _core.py around line 310 moved the line:

kwargs.update(dict(api_key=self.api_key))

to be included only with GET, but not with POST request.

But then when I try to run createListing() I get:

'API request missing api_key or valid OAuth parameters'

Any other ideas?

P.S. When I login on the website to the user I got the token for, on
http://www.etsy.com/your/apps I see the app on the list of authorised
apps, and the API key I use has

Production API 10 per sec. 10,000 per day 10 per sec. 10,000 per
day Full Access

on https://www.etsy.com/developers/your-apps

The consumer key and secret is the same for Sandbox and Production I
suppose, because there is only one given?
Of course the token key and token secret where generated with the
production API. I even tried regenerating it again, but with the same
results.

SnakeO

unread,
Dec 11, 2011, 6:30:24 PM12/11/11
to Etsy API V2
Yes it sounds like you have it all setup correctly. Are you running on
mac or PC?

On Dec 11, 4:41 pm, Miernik <pub...@public.miernik.name> wrote:
> On Dec 11, 10:01 pm, SnakeO <jakech...@gmail.com> wrote:
>
> > Try removing the 'api_key' parameter that gets sent
>
> It seems that currently etsy-python does all requests with api_key, so
> I
> tried to hack it, and in _core.py around line 310 moved the line:
>
> kwargs.update(dict(api_key=self.api_key))
>
> to be included only with GET, but not with POST request.
>
> But then when I try to run createListing() I get:
>
> 'API request missing api_key or valid OAuth parameters'
>
> Any other ideas?
>

> P.S. When I login on the website to the user I got the token for, onhttp://www.etsy.com/your/appsI see the app on the list of authorised


> apps, and the API key I use has
>
> Production API  10 per sec.     10,000 per day  10 per sec.     10,000 per
> day     Full Access
>

> onhttps://www.etsy.com/developers/your-apps

Miernik

unread,
Dec 11, 2011, 7:13:41 PM12/11/11
to Etsy API V2
On Dec 12, 12:30 am, SnakeO <jakech...@gmail.com> wrote:
> Yes it sounds like you have it all setup correctly. Are you running on
> mac or PC?

I'm running Debian.

Python 2.7

SnakeO

unread,
Dec 11, 2011, 9:14:35 PM12/11/11
to Etsy API V2
use a network traffic sniffer to see what the network output shows for
the POST. then paste that here

Miernik

unread,
Dec 12, 2011, 12:30:13 AM12/12/11
to Etsy API V2
On Dec 12, 3:14 am, SnakeO <jakech...@gmail.com> wrote:
> use a network traffic sniffer to see what the network output shows for
> the POST. then paste that here

POST /v2/listings HTTP/1.1
Host: openapi.etsy.com
Content-Length: 528
content-type: multipart/form-data; boundary=----------
ThIs_Is_tHe_bouNdaRY_$
accept-encoding: gzip, deflate
authorization: OAuth realm="http://openapi.etsy.com",
oauth_body_hash="RvkuvCKWTfSNobGaypnRskgpPwo%3D",
oauth_nonce="53708996", oauth_timestamp="1323667604",
oauth_consumer_key="12xx85u7zyjuolg2lqq9ctqa",
oauth_signature_method="HMAC-SHA1", oauth_version="1.0",
oauth_token="82aa6eb0dea248fc97b303e7da7635",
oauth_signature="SPDSMmWg8Zvgw02lGTh7lZ2Xwqo%3D"
user-agent: Python-httplib2/0.7.2 (gzip)

------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="description"

test description
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="price"

25
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="quantity"

1
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="shipping_template_id"

7271435
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="title"

test title
------------ThIs_Is_tHe_bouNdaRY_$--

HTTP/1.1 400 Bad Request
Date: Mon, 12 Dec 2011 05:26:44 GMT
Server: Apache
X-Error-Detail: API request missing api_key or valid OAuth parameters
X-Etsy-Request-Uuid: IdiJlE94acSxeFwvxaKBhlKvtkU8
Content-Length: 53
X-Cnection: close
Content-Type: text/plain;charset=UTF-8

SnakeO

unread,
Dec 12, 2011, 1:05:14 AM12/12/11
to Etsy API V2
any way you can get these vars:

oauth_body_hash="RvkuvCKWTfSNobGaypnRskgpPwo%3D",
oauth_nonce="53708996", oauth_timestamp="1323667604",
oauth_consumer_key="12xx85u7zyjuolg2lqq9ctqa",
oauth_signature_method="HMAC-SHA1", oauth_version="1.0",
oauth_token="82aa6eb0dea248fc97b303e7da7635",
oauth_signature="SPDSMmWg8Zvgw02lGTh7lZ2Xwqo%3D"

to be POSTed instead of just in the header?

Miernik

unread,
Dec 12, 2011, 1:41:26 AM12/12/11
to Etsy API V2
On Dec 12, 7:05 am, SnakeO <jakech...@gmail.com> wrote:
> any way you can get these vars:
> oauth_body_hash="RvkuvCKWTfSNobGaypnRskgpPwo%3D",
> oauth_nonce="53708996", oauth_timestamp="1323667604",
> oauth_consumer_key="12xx85u7zyjuolg2lqq9ctqa",
> oauth_signature_method="HMAC-SHA1", oauth_version="1.0",
> oauth_token="82aa6eb0dea248fc97b303e7da7635",
> oauth_signature="SPDSMmWg8Zvgw02lGTh7lZ2Xwqo%3D"
>
> to be POSTed instead of just in the header?

I tried constructing such POST manually, and got something like this.
Good that the error is now different.
Bad that it's still wrong. Why does it say "parameters_absent" about
parameters I provide?

miernik@przehyba:~$ telnet openapi.etsy.com 80
Trying 38.106.64.22...
Connected to openapi.etsy.com.
Escape character is '^]'.


POST /v2/listings HTTP/1.1
Host: openapi.etsy.com

Content-Length: 1410


content-type: multipart/form-data; boundary=----------
ThIs_Is_tHe_bouNdaRY_$
accept-encoding: gzip, deflate
authorization: OAuth realm="http://openapi.etsy.com",
oauth_body_hash="RvkuvCKWTfSNobGaypnRskgpPwo%3D",
oauth_nonce="53708996", oauth_timestamp="1323667604",
oauth_consumer_key="12xx85u7zyjuolg2lqq9ctqa",
oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oau

user-agent: Python-httplib2/0.7.2 (gzip)

------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="description"

test description
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="price"

25
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="quantity"

1
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="shipping_template_id"

7271435
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="title"

test title
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_body_hash"

RvkuvCKWTfSNobGaypnRskgpPwo%3D
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_nonce"

53708996
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_timestamp"

1323667604
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_consumer_key"

12xx85u7zyjuolg2lqq9ctqa
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_signature_method"

HMAC-SHA1
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_version"

1.0
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_token"

82aa6eb0dea248fc97b303e7da7635
------------ThIs_Is_tHe_bouNdaRY_$
Content-Disposition: form-data; name="oauth_signature"

SPDSMmWg8Zvgw02lGTh7lZ2Xwqo%3D
------------ThIs_Is_tHe_bouNdaRY_$--


HTTP/1.1 403 Forbidden
Date: Mon, 12 Dec 2011 06:36:30 GMT
Server: Apache
X-Error-Detail:
oauth_problem=parameter_absent&amp;oauth_parameters_absent=oauth_consumer_key&amp;oauth_signature&amp;oauth_signature_method&amp;oauth_nonce&amp;oauth_timestamp&amp;oauth_token
X-Etsy-Request-Uuid: EwheU8ZmjDQO8TAkjtv9Eq81ICLP
Content-Length: 176


X-Cnection: close
Content-Type: text/plain;charset=UTF-8

oauth_problem=parameter_absent&amp;oauth_parameters_absent=oauth_consumer_key&amp;oauth_signature&amp;oauth_signature_method&amp;oauth_nonce&amp;oauth_timestamp&amp;oauth_token

Miernik

unread,
Dec 12, 2011, 1:48:22 AM12/12/11
to Etsy API V2
On Dec 12, 7:41 am, Miernik <pub...@public.miernik.name> wrote:
> oauth_signature_method="HMAC-SHA1", oauth_version="1.0", oau

In my previous message this line in the header was cut, but in the
POST I did, its there:

authorization: OAuth realm="http://openapi.etsy.com",
oauth_body_hash="RvkuvCKWTfSNobGaypnRskgpPwo%3D",
oauth_nonce="53708996", oauth_timestamp="1323667604",
oauth_consumer_key="12xx85u7zyjuolg2lqq9ctqa",
oauth_signature_method="HMAC-SHA1", oauth_version="1.0",

oauth_token="82aa6eb0dea248fc97b303e7da7635",
oauth_signature="SPDSMmWg8Zvgw02lGTh7lZ2Xwqo%3D"

The response is still:

HTTP/1.1 403 Forbidden
Date: Mon, 12 Dec 2011 06:45:34 GMT


Server: Apache
X-Error-Detail:
oauth_problem=parameter_absent&amp;oauth_parameters_absent=oauth_consumer_key&amp;oauth_signature&amp;oauth_signature_method&amp;oauth_nonce&amp;oauth_timestamp&amp;oauth_token

X-Etsy-Request-Uuid: FS9uUXnDDbP7FLVyM3cZJGCFHt23

david olick

unread,
Dec 12, 2011, 11:53:07 AM12/12/11
to etsy-...@googlegroups.com
If I remember right, those parameters (oauth_nonce, oauth_consumer_key, etc.) should be in the URL.

--
You received this message because you are subscribed to the Google Groups "Etsy API V2" group.
To post to this group, send email to etsy-...@googlegroups.com.
To unsubscribe from this group, send email to etsy-api-v2...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/etsy-api-v2?hl=en.




--
David Olick
CTO
Oriku Inc.
Reply all
Reply to author
Forward
0 new messages