singingwolfboy / flask-dance

Doing the OAuth dance with style using Flask, requests, and oauthlib.
https://pypi.python.org/pypi/Flask-Dance/
MIT License
1k stars 157 forks source link

Use flask_dance.contrib.google in a blueprint #343

Closed Revisto closed 3 years ago

Revisto commented 3 years ago

Hi, I need to use flask_dance OAuth in a blueprint but I believe that flask_dance's make_google_blueprint make its own blueprint and it's impossible to register that in a blueprint.

AttributeError: 'Blueprint' object has no attribute 'register_blueprint'

I would appreciate any help or solution.

daenney commented 3 years ago
 app.register_blueprint(
        make_google_blueprint(
            scope=['https://www.googleapis.com/auth/userinfo.profile',
                   'https://www.googleapis.com/auth/userinfo.email'),
        url_prefix='/login')
daenney commented 3 years ago

You can't put blueprints in blueprints, they're registered on the app with a URL prefix. That's how Flask works. Perhaps https://stackoverflow.com/questions/33003178/nested-blueprints-in-flask can give you some inspiration if you really want to go try and go down that road.