Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 669445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:09:07+00:00 2026-05-14T00:09:07+00:00

I have a Python Facebook project hosted on Google App Engine and use the

  • 0

I have a Python Facebook project hosted on Google App Engine and use the following code to handle initialization of the Facebook API using PyFacebook.

# Facebook Initialization
def initialize_facebook(f):

    # Redirection handler
    def redirect(self, url):
        logger.info('Redirecting the user to: ' + url)
        self.response.headers.add_header("Cache-Control", "max-age=0")
        self.response.headers.add_header("Pragma", "no-cache")
        self.response.out.write('<html><head><script>parent.location.replace(\'' + url + '\');</script></head></html>')
        return 'Moved temporarily'

    auth_token = request.params.get('auth_token', None)
    fbapi = Facebook(settings['FACEBOOK_API_KEY'], settings['FACEBOOK_SECRET_KEY'], auth_token=auth_token)

    if not fbapi:
        logger.error('Facebook failed to initialize')

    if fbapi.check_session(request) or auth_token:
        pass
    else:
        logger.info('User not logged into Facebook')
        return lambda a: redirect(a, fbapi.get_login_url())

    if fbapi.added:
        pass
    else:
        logger.info('User does not have ' + settings['FACEBOOK_APP_NAME'] + ' added')
        return lambda a: redirect(a, fbapi.get_add_url())

    # Return the validated API
    logger.info('Facebook successfully initialized')
    return lambda a: f(a, fbapi=fbapi)

I’m trying to set it up so that I can drop this decorator on any page handler method and verify that the user has everything set up correctly. The issue is that when the redirect handler gets called, it starts an infinite loop of redirection.

I tried using an HTTP 302 redirection in place of the JavaScript but that kept failing too. Does anyone know what I can do to fix this?

I saw this similar question but there are no answers.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:09:07+00:00Added an answer on May 14, 2026 at 12:09 am

    I was just having the exact same thing happen to me today! What I think is happening is that fbapi.check_session() is not setting fbapi.added correctly. I don’t think the Post-Add URL contains ‘installed’ anymore, but still has ‘fb_sig_added’. The following change (github-esque code) in pyfacebook stopped the infinite redirect for me:

    1244 | 1244 |     if request.method == 'POST':
    1245 | 1245 |         params = self.validate_signature(request.POST)
    1246 | 1246 |     else:
    1247 |      | -       if 'installed' in request.GET:
         | 1247 | +       if 'installed' in request.GET or request.GET['fb_sig_added'] == '1':
    1248 | 1248 |             self.added = True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 434k
  • Answers 434k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Import the Uri class. If you are using Eclipse you… May 15, 2026 at 3:19 pm
  • Editorial Team
    Editorial Team added an answer Matthew is correct about the Shared/NonShared aspect only affecting the… May 15, 2026 at 3:19 pm
  • Editorial Team
    Editorial Team added an answer You have to deal with two view controllers one that's… May 15, 2026 at 3:19 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.