def get_fb_token():
    """Returns access token, optionally launches browser session 
    to get the token via a facebook login.
    esterhui: got this code from the interweb, but can't find the reference now.
    """
    global ACCESS_TOKEN
    if not os.path.exists(TOKEN_FILE):
        print "Logging you in to facebook..."
        webbrowser.open(get_url('/oauth/authorize',
                                {'client_id':APP_ID,
                                 'redirect_uri':REDIRECT_URI,
                                 'scope':'manage_pages,publish_stream,photo_upload,user_photos,video_upload'}))
 
        httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 8080), RequestHandler)
        while ACCESS_TOKEN is None:
            httpd.handle_request()
    else:
        ACCESS_TOKEN = open(TOKEN_FILE).read()

    return ACCESS_TOKEN