Created
December 22, 2011 04:05
-
-
Save marcelcaraciolo/1508880 to your computer and use it in GitHub Desktop.
pyfoursquare Oauth
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import foursquare | |
# == OAuth2 Authentication == | |
# | |
# This mode of authentication is the required one for Foursquare | |
# The client id and client secret can be found on your application's Details | |
# page located at https://foursquare.com/oauth/ | |
client_id = "" | |
client_secret = "" | |
callback = '' | |
auth = foursquare.OauthHandler(client_id, client_secret, callback) | |
#First Redirect the user who wish to authenticate to. | |
#It will be create the authorization url for your app | |
auth_url = auth.get_authorization_url() | |
print 'Please authorize: ' + auth_url | |
#If the user accepts, it will be redirected back | |
#to your registered REDIRECT_URI. | |
#It will give you a code as | |
#https://YOUR_REGISTERED_REDIRECT_URI/?code=CODE | |
code = raw_input('The code: ').strip() | |
#Now your server will make a request for | |
#the access token. You can save this | |
#for future access for your app for this user | |
access_token = auth.get_access_token(code) | |
print 'Your access token is ' + access_token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment