-
Notifications
You must be signed in to change notification settings - Fork 49
PythonCHPP
minj edited this page Mar 19, 2015
·
1 revision
#import rauth
from rauth import OAuth1Service
from rauth import OAuth1Session
from rauth.oauth import HmacSha1Signature
#consumer key and access key after it was retrieved
consumer_key = '<your app consumer key>'
consumer_secret = '<your app consumer secret>'
access_token_key = ''
access_token_secret = ''
chpp = OAuth1Service(
consumer_key=consumer_key,
consumer_secret=consumer_secret,
request_token_url='https://chpp.hattrick.org/oauth/request_token.ashx',
access_token_url='https://chpp.hattrick.org/oauth/access_token.ashx',
authorize_url='https://chpp.hattrick.org/oauth/authorize.aspx',
base_url='http://chpp.hattrick.org/chppxml.ashx',
signature_obj=HmacSha1Signature)
request_token, request_token_secret = chpp.get_request_token(params={'oauth_callback': 'oob'})
print request_token
print request_token_secret
authorize_url = chpp.get_authorize_url(request_token)
print authorize_url
verifier = raw_input("Enter verifier: ")
access_token = chpp.get_access_token(request_token, request_token_secret, params={'oauth_verifier': verifier})
access_token_key = access_token[0]
access_token_secret = access_token[1]
#session = chpp.get_session(token=access_token)
session = OAuth1Session(consumer_key, consumer_secret, access_token=access_token_key, access_token_secret=access_token_secret)
#The way we choose doesn't know about base_url, add the url
r = session.get('http://chpp.hattrick.org/chppxml.ashx', params={'file': 'teamdetails', 'version':'2.4'})