Coder Social home page Coder Social logo

Comments (4)

dsavransky avatar dsavransky commented on July 2, 2024

I'm getting the same behavior (infinite redirect loop), although unfortunately it is intermittent and seems to only occur on the production site (I cannot reproduce it when running the Flask app locally). Were you ever able to solve your problem?

from flask-googlelogin.

joshkendrick avatar joshkendrick commented on July 2, 2024

Nope. Just kinda moved on. Sorry not more help.

from flask-googlelogin.

marksteve avatar marksteve commented on July 2, 2024

Sorry I haven't been able to check on this.
@dsavransky What's different between your local and prod setup/settings?

from flask-googlelogin.

dsavransky avatar dsavransky commented on July 2, 2024

The only real difference is that the production setup is ssl only. So, for local I have:
GOOGLE_LOGIN_REDIRECT_URI='http://localhost:5000/oauth2callback',
GOOGLE_LOGIN_REDIRECT_SCHEME = "http"
and for production:
GOOGLE_LOGIN_REDIRECT_URI='https://servername/oauth2callback',
GOOGLE_LOGIN_REDIRECT_SCHEME = "https"

I am testing login attempts against an internal database of authorized users, so I know that google is actually returning valid information each time (bad login attempts are logged and do not occur when the redirect loop is happening). Here's the oauth2 function:

@app.route('/oauth2callback')
@googlelogin.oauth2callback
def login(token, userinfo, **params):
"""Grab the allowed users"""
"""code returns allowed_user boolean from internal db""""
if not allowed_user:
logging.warning('Bad login attempt by %s', userinfo['email'])
abort(401)
user = users[userinfo['id']] = User(userinfo)
login_user(user)
session['token'] = json.dumps(token)
session['extra'] = params.get('extra')
logging.info('Logged in %s', userinfo['email'])
return redirect(params.get('next', url_for('home')))

I also tried logging current_user.is_authenticated() and it always returns true during a loop, so it seems like login_user is working.

The final difference is that the local version is not really run for long periods of time. On the live version, the loops tend to occur after a user has been logged in for a while. Possibly some kind of expiration mismatch? The cookies generated for the site are all set to expire with the session.

Any ideas? Thanks.

Update: So, switching the wsgi application to running in daemon mode (it was previously running embedded) appears to have completely eliminated the problem No idea why...

from flask-googlelogin.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.