Skip to content

[Bug]: Google OAuth login gets stuck on authorized redirect URI #185

@Felix-Jorge-Flores

Description

@Felix-Jorge-Flores

Description

Description

When performing a Google OAuth login using flutter_web_auth_2, the flow gets stuck on the Google "Authorized redirect URIs" page for http://localhost:3005

Minimal Reproduction

Steps to reproduce the behaviour:

  1. Use flutter_web_auth_2: ^5.0.0-alpha.7
  2. Use the next code
   final googleClientId = 'XXXXXXXXXXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
      final callbackUrlScheme = 'http';

      final authUrl = Uri.https('accounts.google.com', '/o/oauth2/v2/auth', {
        'response_type': 'code',
        'client_id': googleClientId,
        'redirect_uri': 'http://localhost:3005/auth-callback',
        'scope': 'email',
      });

      final result = await FlutterWebAuth2.authenticate(
        url: authUrl.toString(),
        callbackUrlScheme: callbackUrlScheme,
        options: FlutterWebAuth2Options(
          httpsHost: 'localhost:3005',
          httpsPath: '/auth-callback',
        ),
      );
  1. Setup deeplink
  <activity
            android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
            android:exported="true">
            <intent-filter android:label="flutter_web_auth_2">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http"
                android:host="localhost:3005"
                />
            </intent-filter>
        </activity>
  1. Login

Exception or Error

No se puede acceder a este sitio

localhost rechazó la conexión.

Intenta:
Comprobar la conexión.

ERR_CONNECTION_REFUSED

Expected Behaviour

Redirection to app.

Screenshots

Image

Additional context

I'm using ngrok to use localhost:3005 in my Android app

Device

Poco X5 Pro 5G

OS

Window 11 23H2

Browser

Chrome

Flutter version

3.35.2

flutter_web_auth_2 version

^5.0.0-alpha.7

Checklist

  • I have read and followed the entire troubleshooting guide and it has not provided the solution I need.
  • I have provided all the information I can.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions