Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify.Auth not working on Linux (WSL) #5761

Open
3 of 14 tasks
naedx opened this issue Dec 7, 2024 · 2 comments
Open
3 of 14 tasks

Amplify.Auth not working on Linux (WSL) #5761

naedx opened this issue Dec 7, 2024 · 2 comments
Labels
auth Issues related to the Auth Category pending-triage This issue is in the backlog of issues to triage to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided

Comments

@naedx
Copy link

naedx commented Dec 7, 2024

Description

I am able to sign in using Amplify.Auth.signIn() which returns an object that confirms successful login. However, when I fetch the session to check if the user is signed in or to retrieve the tokens to call AppSync it returns an object indicating that the user isn't logged in and no tokens are present.

If I use the connected Authenticator component, the component works fine in itself but again since I cannot retrieve the active token I cannot authenticate against my AppSync API.

I am using developing for Linux on WSL. When I deploy to Chrome (WSL) the Auth session behaves normally.

This has ground my project to a halt.

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Create an Amplify project on WSL with the Linux platform
  2. Add cognito auth and create and validate a user
  3. Define a main function as seen below :

main function and log output:

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';
import 'package:klockedin/amplifyconfiguration.dart';

final username = '<insert username>';
final password = '<insert password>';

void main() async {
  try {
    WidgetsFlutterBinding.ensureInitialized();

    await _configureAmplify();

    // Attempt 1: basic sign in method
    final auth = await Amplify.Auth.signIn(username: username, password: password);

    print('MAIN(1): auth: $auth');

    // Log output:
    //
    // flutter: MAIN(1): auth: SignInResult {
    //   "isSignedIn": true,
    //   "nextStep": {
    //     "additionalInfo": {},
    //     "signInStep": "done",
    //     "missingAttributes": []
    //   }
    // }

    print("MAIN(2): Auth.isSignedIn ${(await Amplify.Auth.fetchAuthSession()).isSignedIn}");
    // Log output:
    //
    // flutter: MAIN(2): Auth.isSignedIn false

    // Attempt 2: sign in by getting the Cognito plugin explicitly
    final cognitoPlugin = Amplify.Auth.getPlugin(AmplifyAuthCognito.pluginKey);

    final auth2 = await cognitoPlugin.signIn(username: username, password: password);
    // Log output:
    //
    print('MAIN(3): auth2: $auth2');
    // flutter: MAIN(3): auth2: SignInResult {
    //   "isSignedIn": true,
    //   "nextStep": {
    //     "additionalInfo": {},
    //     "signInStep": "done",
    //     "missingAttributes": []
    //   }
    // }

    print("MAIN(4): Auth2.isSignedIn ${(await Amplify.Auth.fetchAuthSession()).isSignedIn}");
    // Log output:
    //
    // flutter: MAIN(4): Auth2.isSignedIn false

    print("MAIN(5): Auth2.isSignedIn ${(await cognitoPlugin.fetchAuthSession()).isSignedIn}");
    // Log output:
    //
    // flutter: MAIN(5): Auth2.isSignedIn false
  } catch (e) {
    print('MAIN(6): error: $e');
  }
}

Future<void> _configureAmplify() async {
  try {
    // Add any Amplify plugins you want to use
    final authPlugin = AmplifyAuthCognito();

    await Amplify.addPlugins([
      authPlugin,
      // storagePlugin
    ]);

    await Amplify.configure(amplifyConfig);
    safePrint('Successfully configured');
  } on Exception catch (e) {
    safePrint('Error configuring Amplify: $e');
  }
}

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.5, on Debian GNU/Linux 10 (buster) 5.15.167.4-microsoft-standard-WSL2, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2024.2)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!

pubspec (amplify_* deps):



  amplify_flutter: ^2.0.0
  amplify_auth_cognito: ^2.0.0
  amplify_authenticator: ^2.0.0
  amplify_storage_s3: ^2.0.0

pubspec.lock (amplify_* deps):


amplify_analytics_pinpoint:
    dependency: transitive
    description:
      name: amplify_analytics_pinpoint
      sha256: "383773bca56bb74f0dc20de5c4f9d769e129ef769aff801171f17efaacd10ffe"
      url: "https://pub.dev"
    source: hosted
    version: "2.5.1"
  amplify_analytics_pinpoint_dart:
    dependency: transitive
    description:
      name: amplify_analytics_pinpoint_dart
      sha256: "820f11b335f3a8cbd6273f3be8fe64812df80e9e56b0d38749982fbc66ff68f8"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.6"
  amplify_auth_cognito:
    dependency: "direct main"
    description:
      name: amplify_auth_cognito
      sha256: "3dfa0d55fe0e96beacac479dc0821d807957edc8e396d91465ade545a616a5ff"
      url: "https://pub.dev"
    source: hosted
    version: "2.5.0"
  amplify_auth_cognito_dart:
    dependency: transitive
    description:
      name: amplify_auth_cognito_dart
      sha256: "9b88719e52790d0796cf2d2adfa3b030e4e2954ea9d736b1a932e4a245b01e52"
      url: "https://pub.dev"
    source: hosted
    version: "0.11.7"
  amplify_authenticator:
    dependency: "direct main"
    description:
      name: amplify_authenticator
      sha256: b3ed04f5334c1169cd21d256ae18811258d72fb727485b2825375a95af5f62a7
      url: "https://pub.dev"
    source: hosted
    version: "2.3.1"
  amplify_core:
    dependency: transitive
    description:
      name: amplify_core
      sha256: "1143b5486dceccf8a6807234a277b8643edacdcc032b8a2abc4e0125af3e2a65"
      url: "https://pub.dev"
    source: hosted
    version: "2.5.0"
  amplify_db_common:
    dependency: transitive
    description:
      name: amplify_db_common
      sha256: df14821533f525778ccd58942c137e0ba9b753f4836b152b0211a009ca0b4e3d
      url: "https://pub.dev"
    source: hosted
    version: "0.4.7"
  amplify_db_common_dart:
    dependency: transitive
    description:
      name: amplify_db_common_dart
      sha256: "1bcedfaf97f156da38661ddf89532a21cf801adff9146cd8aac3663c4572f034"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.7"
  amplify_flutter:
    dependency: "direct main"
    description:
      name: amplify_flutter
      sha256: "1aed48ff57761e4ba342a6a2103376de69a52cb988b77c7097eb0cf93ce9535f"
      url: "https://pub.dev"
    source: hosted
    version: "2.5.0"
  amplify_secure_storage:
    dependency: transitive
    description:
      name: amplify_secure_storage
      sha256: "432440443dc5ef9552e6ef20094bd15d2d4aa776eed17f9d756b2673e9c789a6"
      url: "https://pub.dev"
    source: hosted
    version: "0.5.7"
  amplify_secure_storage_dart:
    dependency: transitive
    description:
      name: amplify_secure_storage_dart
      sha256: ec4871ff70c0487ea03b2fd03d2f0328d9b3b9e8b0305aab5a040f6ac3c4bb15
      url: "https://pub.dev"
    source: hosted
    version: "0.5.3"
  amplify_storage_s3:
    dependency: "direct main"
    description:
      name: amplify_storage_s3
      sha256: bbb0584de999a0c9f639dd96ea5c26daff993eb51912feda5775be229116c567
      url: "https://pub.dev"
    source: hosted
    version: "2.5.1"
  amplify_storage_s3_dart:
    dependency: transitive
    description:
      name: amplify_storage_s3_dart
      sha256: "9e32c2e87422bf8236993e91c47f9da5bc292383329ec4ecf079ac8841a23f5b"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.7"

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.24.5

Amplify Flutter Version

2.5.0

Deployment Method

Amplify Gen 2

Schema

No response

@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Dec 7, 2024
@naedx
Copy link
Author

naedx commented Dec 7, 2024

Additionally, when I sign in with the Authenticator on Linux (WSL) I see the following error in the logs:


flutter: ERROR | Authenticator | Error in AuthBloc: SignedOutException {
  "message": "No user is currently signed in"
}

This happens even though the Authenticator is in the logged-in state. This doesn't happen when the target is Chrome (WSL). Maybe this is a clue to what's going on.

@Equartey
Copy link
Contributor

Equartey commented Dec 9, 2024

Hi @naedx, thanks for reporting this issue. We will investigate it and get back to you with any updates.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Dec 9, 2024
@Equartey Equartey added auth Issues related to the Auth Category to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth Category pending-triage This issue is in the backlog of issues to triage to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided
Projects
None yet
Development

No branches or pull requests

2 participants