oauth api access updated, please confirm

1 view
Skip to first unread message

ivan.k...@gmail.com

unread,
Jun 1, 2009, 4:43:45 PM6/1/09
to Tipjoy Developers
Hi,

I just posted an update which should fix some bugs in the Tipjoy API.

The /api/tweetpayment/notify/ endpoint actually returns transaction
data. You can test this with:
curl http://tipjoy.com/api/tweetpayment/notify/ -d tweet_id=1940609292

The authorization has become much more consistent across endpoints,
which I believe was the cause of some of the problems. I tested with
an OAuth consumer credential set that belongs to @bwast (not @tipjoy,
as was the case before).

Also, when passing us twitter credentials or an OAuth header, the
default behavior is now to create a Tipjoy account for Twitter
accounts that aren't in our system. You can designate that you don't
want an account created by adding the parameter create_account=false

I expanded our test suite, but please test that you can consistently
access the API via 3rd party oauth headers. Let me know if you have
any other trouble.

Ivan
http://tipjoy.com

Kjell Bublitz

unread,
Jun 1, 2009, 5:10:17 PM6/1/09
to tipjoy-d...@googlegroups.com
Hi Ivan,

i could generate a login-link with my OAuth app and some random user.
I guess (hope) all other endpoints still work too. Will keep you posted.

PS: Just a couple hours to contest deadline, right?

Best,
Kjell

ma...@veodia.com

unread,
Jun 1, 2009, 8:08:25 PM6/1/09
to Tipjoy Developers
Getting a user balance still works like it did prior. However,
getting a loginlink url gives me this:

{"reason": "invalid twitter_oauth_header. id:1", "request": "/api/user/
loginlink/", "result": "failure"}

id:1 looks new.

Does the order of the oauth header vars matter?

thx...
-matt

On Jun 1, 2:10 pm, Kjell Bublitz <m3nt0r...@gmail.com> wrote:
> Hi Ivan,
>
> i could generate a login-link with my OAuth app and some random user.  
> I guess (hope) all other endpoints still work too. Will keep you posted.
>
> PS: Just a couple hours to contest deadline, right?
>
> Best,
> Kjell
>
> Am 01.06.2009 um 22:43 schrieb ivan.kiri...@gmail.com:
>
>
>
> > Hi,
>
> > I just posted an update which should fix some bugs in the Tipjoy API.
>
> > The /api/tweetpayment/notify/ endpoint actually returns transaction
> > data. You can test this with:
> > curlhttp://tipjoy.com/api/tweetpayment/notify/-d tweet_id=1940609292

Ivan Kirigin

unread,
Jun 1, 2009, 8:12:18 PM6/1/09
to tipjoy-d...@googlegroups.com, Tipjoy Developers
I added id's to know where in the code the error occurs.

The order of params doesn't matter.

I'll take a look at the issues later tonight.

Ivan
via iphone
http://tipjoy.com 617-777-4317

Ivan Kirigin

unread,
Jun 2, 2009, 10:22:31 AM6/2/09
to Tipjoy Developers
I misunderstood your question.

The order of the parameters in the OAuth header DOES matter
http://oauth.net/core/1.0/#anchor14

You should just use a library to take care of this step though. I've
used:
http://code.daaku.org/python-oauth/

I posted some code about this here:
http://tipjoy.com/api/#authentication

In the code below, oauth_request.to_header will call compose_qs from
the urlencoding lib. The compose_qs call sorts the authorization
parameters
http://github.com/nshah/python-urlencoding/blob/fafc630f3368559488dcb23dd4859669389a2a6f/urlencoding/__init__.py#L54

from oauth import OAuthRequest # from http://code.daaku.org/python-oauth/
from oauth.signature_method.hmac_sha1 import
OAuthSignatureMethod_HMAC_SHA1
def get_oauth_header(oauth_token, oauth_token_secret,
twitter_consumer_key, twitter_consumer_secret):
url = 'http://twitter.com/account/verify_credentials.json'
consumer = {'oauth_token': twitter_consumer_key,
'oauth_token_secret': twitter_consumer_secret}
token = {'oauth_token': oauth_token, 'oauth_token_secret':
oauth_token_secret }
oauth_request = OAuthRequest( url )
oauth_request.sign_request(OAuthSignatureMethod_HMAC_SHA1,
consumer, token=token)
return oauth_request.to_header()

If you're not doing this, the header will likely be invalid.

You can test for yourself if the header is valid. Here is the code I
use:

def twitter_verify_credentials_3rd_part_oauth( auth_header ):
page_request = urllib2.Request( 'http://twitter.com/account/
verify_credentials.json', headers={'Authorization' : auth_header} )
try:
return json.read( urllib2.urlopen(page_request).read() )
except:
return False
return False

Ivan
http://tipjoy.com

On Jun 1, 8:12 pm, Ivan Kirigin <ivan.kiri...@gmail.com> wrote:
> I added id's to know where in the code the error occurs.
>
> The order of params doesn't matter.
>
> I'll take a look at the issues later tonight.
>
> Ivan
> via iphonehttp://tipjoy.com617-777-4317
>
Reply all
Reply to author
Forward
0 new messages