Skip to content

Token Cache is not invalidated on Logout #131

@eliast96

Description

@eliast96

Issue description

Logging out from msal is not clearing token cache, and then when trying to login again to a different email it automatically logs in to the last connected mail.

Here is my code for logging out:
const String clientId = "";
const String tenantId = "";
const String redirectUriMacos =
"msauth.msal://auth";
const List scopes = [
'https://graph.microsoft.com/Mail.Send',
];
var redirectUri =
(Platform.isIOS || Platform.isAndroid) ? null : redirectUriMacos;

final msalAuth = await SingleAccountPca.create(
clientId: clientId,
androidConfig: AndroidConfig(
configFilePath: 'assets/msal_config.json',
redirectUri: redirectUri ??
"msauth://com.ngm.pixcar/",
),
appleConfig: AppleConfig(
authorityType: AuthorityType.aad,
broker: Broker.webView,
),
);

await msalAuth.signOut();

and then when i do
await msalAuth.acquireTokenSilent(scopes: scopes)
or even:
await msalAuth.acquireToken(scopes: scopes)

it automatically logs in back to the mail i logged out from...
So i am unable to switch account.

MSAL Auth Plugin Version

3.3.0

Platforms

  • Android
  • iOS
  • MacOS

Account Mode

Single

Android JSON Configuration

Minimal Dart Code Snippet

const String clientId = "<hidden>";
  const String tenantId = "<hidden>";
  const String redirectUriMacos =
      "msauth.msal<hidden>://auth";
  const List<String> scopes = [
    'https://graph.microsoft.com/Mail.Send',
  ];
  var redirectUri =
      (Platform.isIOS || Platform.isAndroid) ? null : redirectUriMacos;

  final msalAuth = await SingleAccountPca.create(
    clientId: clientId,
    androidConfig: AndroidConfig(
      configFilePath: 'assets/msal_config.json',
      redirectUri: redirectUri ??
          "msauth://com.ngm.pixcar/<hidden>",
    ),
    appleConfig: AppleConfig(
      authorityType: AuthorityType.aad,
      broker: Broker.webView,
    ),
  );

  await msalAuth.signOut();

Relevant log output

Before submitting, please confirm

  • I have checked the documentation and it does not solve my issue.
  • I have run the example app and the issue still exists.

Flutter Doctor Output

Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.27.1, on macOS 15.7.3 24G419 darwin-arm64, locale en-IL)
    ! Flutter version 3.27.1 on channel [user-branch] at /Users/ngm_dev/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.108.1)
[✓] Connected device (6 available)
    ! Error: Browsing on the local area network for Nadine El. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions