I am using devise_auth_token
gem in my rails-api
app. I used omniauth_google_oauth2
gem with my app for auth but it was very buggy so I decided to follow a different approach.
I have a route in my api app that will response
{ "url": google-oauth-login-url }
The frontend app use that route to put it in the login with google btn.
After a user click in the btn they will be redirected to google oauth page and after filling in the details they will be then redirected to the frontend home page with the google code in the url.
The frontend app will send a req to the api server with the code and the server will req to the google server again to exchange that google code for access-token, refresh token and all that.
After the server receives those token, the server again makes another req to the google server to fetch user profile.
I dont know how to register the user after I get the user profile info.
How do i register it ? After registering it, how do I sign it in or send a authentication token to the frontend app? The authentication token will be used in every headers while making the api call.
Any idea?