Exemplo n.º 1
0
def fe_request_token_ready(request):
  """
  OAuth dance for Fire Eagle, callback URL
  """
  query = request.environ['QUERY_STRING']
  query_values = query.split("&")
  values = {}
  for qv in query_values:
      (key, value) = qv.split("=")
      values[key] = value
  oauth_verifier = values['oauth_verifier']
  oauth_token = values['oauth_token']
  CONSUMER_KEY = FE_CONSUMER_KEY
  CONSUMER_SECRET = FE_CONSUMER_SECRET
  fe = FireEagle( CONSUMER_KEY, CONSUMER_SECRET )
  token = Token.gql( "WHERE user = :1", str(request.user) ).get()
  oauth_token = oauth.OAuthToken.from_string( token.fe_request_token )
  fe = FireEagle( CONSUMER_KEY, CONSUMER_SECRET )
  access_token = fe.access_token( oauth_verifier=oauth_verifier, token=oauth_token )
  token.fe_token = str(access_token)
  token.put()
  return redirect( "/" )
Exemplo n.º 2
0
# Die if we've already authorized
if path.exists( settings.AUTH_FILE ):
    print "It looks like you already authorized Fire Eagle. Bye!"
    exit()

def pause( prompt='hit to continue' ):
    return raw_input( '\n' + prompt + '\n' )

fe = FireEagle( settings.CONSUMER_KEY, settings.CONSUMER_SECRET )

## Step 1 - Get a request token

request_token = fe.request_token()

## Step 2 - Ask the user to authorize the application, using that request token

auth_url      = fe.authorize( request_token )
print auth_url
pause( 'Please authorize the app at that URL' )

## Step 3 - Convert the request token into an access token

access_token  = fe.access_token( request_token )

## (Step 4 - save the access token)

token_file = open( settings.AUTH_FILE, 'w' )
try:
    pickle.dump( access_token, token_file )
finally:
    token_file.close()
Exemplo n.º 3
0
from fireeagle_api import FireEagle
fe = FireEagle( "MLxYXHDkLiA8", "r9qanNnpBvFX3mF3xmI98Hsjsg3zJ389" ) # dev
application_token = fe.request_token()
auth_url          = fe.authorize( application_token )
print auth_url
pause( 'Please authorize the app at that URL!' )
user_token        = fe.access_token( application_token )
print fe.lookup( user_token, q='London, England' )
print fe.user( user_token )
Exemplo n.º 4
0
    exit()

def pause( prompt='hit to continue' ):
    return raw_input( '\n' + prompt + '\n' )

fe = FireEagle( settings.CONSUMER_KEY, settings.CONSUMER_SECRET )

## Step 1 - Get a request token

request_token = fe.request_token()
# Alternately, include a callback url when getting a request token
# request_token = fe.request_token( oauth_callback="http://example.com/cb")

## Step 2 - Ask the user to authorize the application, using that request token

auth_url      = fe.authorize( request_token )
print 'Please authorize this application:'
print auth_url
oauth_verifier = pause( 'Please enter the verification code:' )

## Step 3 - Convert the request token into an access token, using the verification code that was provided

access_token  = fe.access_token( token=request_token, oauth_verifier=oauth_verifier )

## (Step 4 - save the access token)

token_file = open( settings.AUTH_FILE, 'w' )
try:
    pickle.dump( access_token, token_file )
finally:
    token_file.close()