Author

Topic: 796.com API woes. What do i do wrong? (Read 951 times)

796
hero member
Activity: 532
Merit: 500
February 12, 2014, 02:28:33 AM
#2
Hi there,

The api has been fixed, please check it out.

Best,
796 Exchange
full member
Activity: 170
Merit: 104
January 18, 2014, 03:24:37 AM
#1
Hi all, does anybody have authenticated parts of the 796.com API working? Or maybe even actual sample code? I am trying to make a script to regularly fetch my positions and balances.

Getting an access token works fine:
Code:
In [2]: url
Out[2]: 'https://796.com/oauth/token?appid=12345×tamp=1390028823&apikey=1234f38c-5678-07a3-90ab-54cb-411f9d4c&secretkey=SECRETEDITED&sig=NGUyMTAxM2QwZmMyNjM1YzUzNWIzNmYyMjY1YzU0MmFkMmNhODI2NA%3D%3D'

In [3]: import requests

In [4]: requests.get(url).json()
Out[4]:
{u'data': {u'access_token': u'12345%7CFRiesmsE0kQQstbBkt3LhR%2BI2%2BKQzOkSdKRkvXXZxWtJ1
TrE3tQ%2BwAwH6mVYAReQ',
  u'rights': u'weeklyfutures,ltcfutures,btcusd,ltcusd',
  u'uid': u'123456',
  u'username': u'EDITED'},
 u'errno': u'0',
 u'msg': u'success'}

'
# slightly edited
In [21]: requests.get(url).json()['data']['access_token']
Out[21]: u'12345%7CzaBj78CvQ5Sw.....MgW%2BBzoEewFkn71VYRAKQ'

In [22]: urllib.unquote(requests.get(url).json()['data']['access_token'])
Out[22]: u'12345|UCqzlOzgeF...........Qw3/zA9AUeg'

I suspect the last version is the correct one (unquoted). Anyway, I'm unable to figure out how to actually use these tokens, all my attempts so far has led to a singular result:

# sligthtly edited for security
In [25]: print q1
12345|Oj2EBShZ..............................................sa/x68Q+oFwiOkD4USdQ

In [26]: requests.get('https://796.com/v1/user/get_info?%s' % q1)
Out[26]:

In [27]: _.text
Out[27]: u'Access Denied!'

In [28]: requests.get('https://796.com/v1/user/get_info?access_token=%s' % q1)
Out[28]:

In [29]: _.text
Out[29]: u'Access Denied!'


Hoping for ideas!
Thanks!



UPDATE: It boils to me not understanding oauth at all. Anyways, I do receive two fields separated by a pipe in the data.access_token response object. First field is same as APP ID and the other one i guuess i the secret token. I'm trying this with python 2.7 rauth, still looking for that correct magic incantation.

Jump to: