Search code examples
androidruby-on-railswebviewoauthgoogle-oauth

Integrating Google Sign-In with WebView in Android


Our Android app is a minimal wrapper around our mobile-friendly website. This is by design.

Google OAuth is one means by which users can authenticate. With the announcement that WebView's will be blocked from Google OAuth, we are now looking at how to move forward.

My current plan is:

  1. Use a JavascriptInterface to invoke native code when someone clicks on the web app's Sign in With Google button
  2. Use Google Sign In to authenticate the user on the mobile app side.
  3. Somehow send this authentication to the web server. Should I just redirect the user to the existing oauth callback URL?

Step 3 is where I'm not sure what the best approach is. It's a Ruby on Rails application using Omniauth.

Are there any examples of integrating Google Sign In with an almost entirely WebView-based application? Is this approach the right way to go about it?


Solution

  • The solution described in Authenticate with a backend server sounds just like what you want to do in step 3, though without using the OAuth callback URL. Unfortunately, I could not find any reference on how to use it with OmniAuth.