Skip to main content
All CollectionsPWA Questions
Google oAuth2 is not working in my PWA on iOS. Why?
Google oAuth2 is not working in my PWA on iOS. Why?

Common reasons for issues with Google sign-in in PWAs on iPhones and iPads

Kevin Basset avatar
Written by Kevin Basset
Updated over 5 months ago

Until 2018, signing in via Google in a PWA wasn't working properly. However, this has since been fixed. In 2024, Google sign-in works just fine in installed PWAs on iOS.

If you're encountering problems with Google sign-in within your app, it's likely related to errors in your own Google OAuth integration.

Demo

You can install this demo PWA as follows to see how the Google sign-in flow should work:

  1. Install the Progressier PWA to your homescreen

  2. Open it from your homescreen. You should be redirected to the login page.

  3. Click on the "Sign in with Google" button

  4. Follow Google's instructions to log in

  5. You should be redirected to the Progressier dashboard without issues

Solution 1: Handle duplicate auth requests properly

Problem: During the login process, the OAuth2 callback handler might receive duplicate requests โ€” one from the PWA and another from the in-app browser.

  1. Initial Response: The handler requests an OAuth token from Google using the authorization code. This successfully logs in the user the first time.

  2. Subsequent Request Issue: A second request using the same code leads to a 400 invalid_grant error, disrupting the sign-in flow.

Strategies to Address This:

  • Implement Caching: Adjust your OAuth2 callback handler to cache the first successful response. Use settings such as Cache-Control: public, max-age=300, immutable to manage this.

  • Ensure Redirects: Modify the handler to redirect to your post-login page regardless of the response's status, preventing disruption from the second request.

Solution 2: Prompt users to install your PWA after login

With iOS version 16.7 and later, adding a PWA to the home screen after login transfers the domain's existing cookies.

This means users can bypass the login page altogether if already authenticated. So a viable strategy is to ask users to install your PWA only when they're already logged in. Progressier can help you configure prompts accordingly.

Did this answer your question?