-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
devise omniauth redirect issue after installing devise_token_auth #1088
Comments
Hey @sparshsamir1993 did you see this post? Are you maybe forgetting a concern? |
The logs when i hit
Already have concern included in
Also in the normal webapp the user wont be set by token. By facebook ,login. THis user controler is for the api users an my /users/omniauth_callbacks_controller.rb
|
@zachfeldman any clue? |
Nope, sorry I'm all out of ideas. |
Maybe because you have |
Hey, closing this. Searched for this " ERROR -- omniauth: (facebook) Authentication failure! invalid_credentials: OAuth2::Error, :" Got that i was using a pretty old version of omniauth-facebook. Had to use at least '4.1' Thanks a lot. |
I had a working devise+ facebook omniatuh application. After configuring this gem to make an api for my app, I have started getting the issue.
In the web app, i use the omniauth callback method for user sign in but for the API, I use Koala gem and native facebook plugin to identify the user.
I have the routes configured as...
`
Rails.application.routes.draw do
devise_for :users,:controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }, skip: ["devise_token_auth/concerns"], via: [:get, :post]
namespace :admin do
resources :users
end
namespace :api do
namespace :v1 do
resources :users, only: [:index, :show]
mount_devise_token_auth_for 'User', at: 'auth', skip: [:omniauth_callbacks], via: [:get, :post]
post '/auth/authenticatFacebookToken' => 'users#authenticatFacebookToken', as: :fbtokenauth
end
end
root to: 'visitors#index'
end
`
So now when I click login to facebook in my app, it redirects to "http://localhost:3000/api/v1/auth/sign_in#_=_"
And, the error "{"errors":["Use POST /sign_in to sign in. GET is not supported."]}"
my omniauth callbacks controller
`
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
# You need to implement the method below in your model (e.g. app/models/user.rb)
@user = User.from_omniauth(request.env["omniauth.auth"])
sign_in @user
redirect_to user_facebook_omniauth_callback_path
set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
end
end
`
How can I fix this?
Thanks!!
The text was updated successfully, but these errors were encountered: