ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
51 stars 50 forks source link

[Bug]: Telegram Authentication in FlutterWebAuth2 CANCELED #96

Open JEFFERSeX opened 7 months ago

JEFFERSeX commented 7 months ago

Description

I am encountering an issue with Telegram authentication in my Flutter app using the FlutterWebAuth2 package. The authentication process seems to be failing, and I consistently receive the error PlatformException(CANCELED, User canceled login, null, null).

Minimal Reproduction

Steps to reproduce the behaviour:

  1. Use the following code:

    void _signIn() async {
      try {
        final result = await FlutterWebAuth2.authenticate(
          url: Uri(
            scheme: 'https',
            host: 'oauth.telegram.org',
            path: 'auth',
            queryParameters: {
              'bot_id': '**********',
              'origin': 'https://socialnayasvyaz.ru',
              'embed': '1',
              'request_access': 'write',
              'return_to': 'https://socialnayasvyaz.ru',
            },
          ).toString(),
          callbackUrlScheme: 'https',
        );
    
        print(result);
      } on PlatformException catch (e) {
        GetIt.I<Talker>().handle(e, null, 'Error during Telegram login');
      }
    }
  2. AndroidManifest:
    <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="https" />
            <data android:host="socialnayasvyaz.ru" />
        </intent-filter>
    </activity>

Exception or Error

PlatformException(CANCELED, User canceled login, null, null).

Expected Behaviour

The Telegram authentication should be successful, and the user should be redirected back to the specified callback URL.

Screenshots

No response

Additional context

No response

Device

Android emulator Pixel 3a API 34

OS

Android 14

Browser

Chrome

Flutter version

3.16.7

flutter_web_auth_2 version

3.1.1

Checklist