xauth using python-oauth2
Asked Answered
W

1

8

I am trying to implement xauth for instapaper using python-oauth2. I am able to find samples for oauth but I didnt find any for xauth. Can someone share samples or the api documentation?

Welltodo answered 31/3, 2011 at 16:38 Comment(0)
W
11

here is the code that worked for me finally


consumer_key=<key>
consumer_secret=<secret>
access_token_url = 'https://www.instapaper.com/api/1/oauth/access_token'

consumer = oauth.Consumer(consumer_key, consumer_secret)
client = oauth.Client(consumer)
client.add_credentials(instaaccount,instapassword)

params = {}
params["x_auth_username"] = instaaccount
params["x_auth_password"] = instapassword
params["x_auth_mode"] = 'client_auth'

client.set_signature_method = oauth.SignatureMethod_HMAC_SHA1()
resp, token = client.request(access_token_url, method="POST",body=urllib.urlencode(params))
Welltodo answered 4/4, 2011 at 16:45 Comment(1)
I was able to get a different xAuth API to work without the add_credentials line, so it's not strictly necessary, depending on the API.Iapetus

© 2022 - 2024 — McMap. All rights reserved.