lynndylanhurley / devise_token_auth

Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
Do What The F*ck You Want To Public License
3.54k stars 1.13k forks source link

Possible to use Google oauth2 with devise_token_auth as well as devise? #1619

Open reisner opened 5 months ago

reisner commented 5 months ago

Hi there,

I've got a web app that also functions as an API for a mobile app. Devise is used for the user login, and devise_token_auth for the mobile app login. This is working fine for database users, however I cant get it working for google oauth2.

When I try to use google oauth2 via devise_token_auth, I set config.omniauth_prefix. However, this seems to overwrite the path for omniauth callbacks for base devise. I believe i need to have two separate endpoints for omniauth via devise_token_auth and for devise. Is that true? Is it possible to have both working at the same time?

Settings:

  devise_for :users, controllers: {
    omniauth_callbacks: 'users/omniauth_callbacks',
    sessions: 'users/sessions',
    registrations: 'users/registrations'
  }

  namespace :api do
    namespace :v1 do
      mount_devise_token_auth_for 'User', at: 'auth', defaults: {format: 'json'}
    end
  end

Versions: devise_token_auth (1.2.2) rails (7.1.3.2) devise (~> 4.9) ruby 3.2.3p157