Skip to content

[Bug]: Telegram Authentication in FlutterWebAuth2 CANCELED #96

Open
@JEFFERSeX

Description

@JEFFERSeX

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

  • 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