Google/Facebook OAuth2 in Rails Front-end app with rails-api as webservice
First, you need to implement the google login in front-end
. Here is google documentation on implementing google sign-in in javascript
. google will provide you with information on user's profile. After you got the information, you can send it to you service. On server side/Backend you can do whatever with this information. That's on you.
Additionally, this documentation might be helpful for your case.
You could use omniauth-google-oauth2 gem
Main idea is to implement this into Devise
.
Good solution You could find this.
With this solution, it is no problem if You use frontend/backend.So, You should pay attention on next steps:
User Model:
devise :database_authenticatable, ... , :omniauthable
Devise.rb:
config.omniauth :google_oauth2, ENV['GP_key'], ENV['GP_secret'], { name: 'google', scope: 'plus.login, userinfo.email, userinfo.profile, ... youtubepartner, youtubepartner-channel-audit', prompt: "select_account" }
Next steps as in solutions..
In my project it is workable with frontend/backend too.So, if you find difficulties, I will be glad do advice for it solving...
Update: for Android versions of frontend.You should not do authentication/authorization frontend on Google.You should do it on backend side.You could use webtools or other suitable ways for walking around Devise
and Google auth pages
...