Dev tools for oAuth implementation

I had already quite the situation that I needed to call an #oAuth protected API for e.g. a web application, without having implemented the enduser facing oAuth-Transactions. 

If you want to access Google APIs, you can use Google oAuth Playground (which was presented today) at http://googlecodesamples.com/oauth_playground/index.php .

Unfortunately this tool just serves Googles APIs, so I wanted to share the small code snippet I use to create access token for arbitrary APIs from the python command line:

import tweepy

CONSUMER_KEY = ‘paste your Consumer Key here’

CONSUMER_SECRET = ‘paste your Consumer Secret here’

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)

auth_url = auth.get_authorization_url()

print ‘Please authorize: ’ + auth_url

verifier = raw_input(‘PIN: ‘).strip()

auth.get_access_token(verifier)

print “ACCESS_KEY = ‘%s’” % auth.access_token.key

print “ACCESS_SECRET = ‘%s’” % auth.access_token.secret

You can find the snippet also on Pastebin: http://pastebin.com/np7rip3b

About these ads

, ,

  1. Hinterlasse einen Kommentar

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Verbinde mit %s

Follow

Bekomme jeden neuen Artikel in deinen Posteingang.

Schließe dich 691 Followern an

%d Bloggern gefällt das: