def get_access_token_from_code(code, redirect_uri, app_id, app_secret):
 args = {'code': code, 'redirect_uri': redirect_uri, 'client_id': app_id, 'client_secret': app_secret}
 response = urllib.urlopen((('https://graph.facebook.com/oauth/access_token' + '?') + urllib.urlencode(args))).read()
 query_str = parse_qs(response)
 if ('access_token' in query_str):
  result = {'access_token': query_str['access_token'][0]}
  if ('expires' in query_str):
   result['expires'] = query_str['expires'][0]
  return result
 else:
  response = json.loads(response)
  raise GraphAPIError(response)

def get_access_token_from_code ( code , redirect_uri , app_id , app_secret ) : args = { 'code' : code , 'redirect_uri' : redirect_uri , 'client_id' : app_id , 'client_secret' : app_secret } response = urllib . urlopen ( ( ( 'https://graph.facebook.com/oauth/access_token' + '?' ) + urllib . urlencode ( args ) ) ) . read ( ) query_str = parse_qs ( response ) if ( 'access_token' in query_str ) : result = { 'access_token' : query_str [ 'access_token' ] [ 0 ] } if ( 'expires' in query_str ) : result [ 'expires' ] = query_str [ 'expires' ] [ 0 ] return result else : response = json . loads ( response ) raise GraphAPIError ( response )
get an access token from the "code" returned from an oauth dialog .