Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Social log in only #27

Closed
rjbriody opened this issue Dec 15, 2013 · 6 comments
Closed

Social log in only #27

rjbriody opened this issue Dec 15, 2013 · 6 comments

Comments

@rjbriody
Copy link

It would be awesome if it were possible to log in w/ a social account only. Meaning there would be no need to enter email or passwords.

Apparently others are looking for this as well (I did not create this stack post): http://stackoverflow.com/questions/17998627/using-flask-social-with-oauth-providers-only-no-local-registration-login-form

@eriktaubeneck
Copy link
Collaborator

Hey @rjbriody. This is doable without too much extra work using the @login_failed.connect_via decorator. With app as your instance of a Flask app, it would look like

@login_failed.connect_via(app):
def on_login_failed(sender, provider, oauth_response):
    connection_values = get_connection_values_from_oauth_response(provider, oauth_response)
    ds = current_app.security.datastore
    user = ds.create_user( ... ) #fill in relevant stuff here
    ds.commit()
    connection_values['user_id'] = user.id
    connect_handler(connection_values, provider)
    login_user(user)
    db.commit()
    return render_template('success.html')

As for filling in the relevant stuff for creating the user, I just create a random string for the password, and haven't had issues leaving the email null. Hope that helps!

@rjbriody
Copy link
Author

Hey this is way better than the ugly hack I made. I'm excited to try it out. Thanks!

@eriktaubeneck
Copy link
Collaborator

Great, glad to see more people using Flask-Social!

@JagCesar
Copy link

JagCesar commented Jan 6, 2014

👍

@Legend
Copy link

Legend commented Jul 10, 2014

@rjbriody @eriktaubeneck Just wondering if you guys wrote a tutorial somewhere about how to do this (a small complete application). Would be a nice tutorial for beginners like me. :)

@exhuma
Copy link

exhuma commented Mar 1, 2016

This really should be in the docs!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants