Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token is not generated when login through facebook #1099

Closed
lateshkudnekar opened this issue Feb 23, 2018 · 5 comments
Closed

Token is not generated when login through facebook #1099

lateshkudnekar opened this issue Feb 23, 2018 · 5 comments

Comments

@lateshkudnekar
Copy link

lateshkudnekar commented Feb 23, 2018

Hi,
I'm developing a user registration and login feature for my ember app, rails api as backend. After getting user info and token from facebook, i am creating a new user and after calling sign_in tokens are not generated, plz provide suggestion (No errors on log)

  def redirect_callbacks
    find_for_oauth(request.env["omniauth.auth"])
  end

  private
  def find_for_oauth(auth)
    email = auth.info.email
    user = User.where(:email => email).first if email
    # Create the user if it's a new registration
    if user.nil?
      user = User.new(
        name: auth.extra.raw_info.name,
        email: email,
        password: Devise.friendly_token[0,20],
        uid: auth.uid,
        provider: auth.provider,
      )
      user.save!
      sign_in user
    else
      sign_in user
    end
  end
end

Rail Api

  • Rails v5.0.
  • devise_token_auth (0.1.43.beta1)
  • devise 4.0.0.rc2
  • omniauth 1.6.1
  • omniauth-facebook 4.0.0
  • omniauth-oauth2 1.4.0

Ember

  • torii 0.10.1
  • ember-simple-auth 1.1.0
@zachfeldman
Copy link
Contributor

Hey @lateshkudnekar, have you looked at the jtoker, redux-token-auth, or similar repositories for guidance?

@mikeover
Copy link

@zachfeldman I'm in a similar spot. I'm using redux-token-auth for my frontend which is a separate app and repo from my Rails 5 backend API. From the frontend, I'm redirecting the user to /omniauth/twitter, getting sent to Twitter for auth, getting back to the callback on the backend at /auth/twitter/callback but then it just stops there.

It creates a user, creates an auth token but I never back to the frontend app. Where am I going wrong here?

@zachfeldman
Copy link
Contributor

@mikeover except you're using Rails 5 API and this user probably wasn't.

@mikeover
Copy link

He is, it says explicitly in the OP that he's using Rails 5 API.

@zachfeldman
Copy link
Contributor

Oh ok, I kind of interpreted that as, "A Rails API" vs. "Rails 5 in API-only mode". My bad!

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

No branches or pull requests

3 participants