Spot any errors? let me know, but Unleash your pedant politely please.

Thursday 20 December 2012

Still feeling a bit stupid

I saw yesterday that requests v1.0 was out.  I revisited it in the hope that I wouldn't feel so stupid.

It still doesn't work for me. In a different way.  I tried the three signature types I think are available, but all are rejected by the server.

import requests
from requests_oauthlib import OAuth1

consumer_key        = u"that"
consumer_secret     = u"would"
access_token_key    = u"be"
access_token_secret = u"telling"
                                 
for signature_type in ('auth_header','body','query'):
    auth = OAuth1(client_key            = consumer_key,
                  client_secret         = consumer_secret,
                  resource_owner_key    = access_token_key,
                  resource_owner_secret = access_token_secret,
                  signature_type        = signature_type)
    
    r = requests.get(u'https://api.projectplace.com/1/user/me/profile.json', auth=auth)
    
    print signature_type
    print r.encoding
    print r.text
    print r.json

gives me

auth_header
ISO-8859-1
Could not properly validate "oauth_consumer_key".
>

body
ISO-8859-1
Could not properly validate "oauth_consumer_key".
>

query
ISO-8859-1
Could not properly validate "oauth_consumer_key".
>
administrators-macbook-pro-2:ProjectPlace (requests) bob$ 

Ho hum.

2 comments:

  1. Tried again. Requests 1.1.0 gives me the same results. On the plus side, it just takes a minute to confirm. At some point it'll probably work.

    ReplyDelete
  2. Hmmm. Poked around some documentation. Remembered that the oauth part had been spit out. $ sudo pip install requests-oauthlib --upgrade
    Now working.

    ReplyDelete