supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
742 stars 183 forks source link

`Supabase.initialize` throws an `AuthException` when an `accessToken` is provided #1072

Closed gibsorya closed 2 weeks ago

gibsorya commented 3 weeks ago

Describe the bug Hello! I am trying to provide an Auth0 access token to Supabase, but find myself unable to do so. After a little debugging I discovered that the Supabase initialize code is still initializing an instance of SupabaseAuth even with an accessCode, which references Supabase.instance.client.auth. I believe this was introduced in #999

To Reproduce Steps to reproduce the behavior:

  1. Initialize Supabase with an access token

Expected behavior Supabase.initialize should accept a custom access token.

Screenshots Here is the call stack for this bug: image

Here is the exception being thrown: image

Version: On Linux/macOS

├── supabase_flutter 2.7.0
│   ├── supabase 2.4.0
│   │   ├── functions_client 2.3.3
│   │   ├── gotrue 2.9.0
│   │   ├── postgrest 2.2.0
│   │   ├── realtime_client 2.3.0
│   │   ├── storage_client 2.1.0

Additional context For context, here is the code where I am initializing Supabase:

  final auth0 = Auth0(Environment.auth0Domain, Environment.auth0ClientId);

  await Supabase.initialize(
    url: Environment.supabaseUrl,
    anonKey: Environment.supabaseAnonKey,
    accessToken: () async {
      final credentials = await auth0.credentialsManager.credentials();
      return credentials.accessToken;
    },
  );

Here is the exception message:

Unhandled Exception: AuthException(message: Supabase Client is configured with the accessToken option, accessing supabase.auth is not possible., statusCode: null, errorCode: null)
Vinzent03 commented 3 weeks ago

Please show the actual thrown exception. It should contain a message or similar to give some context on what's the issue. It should be shown in vscode when debugging and printed to the console, if not caught and handled.

gibsorya commented 3 weeks ago

Please show the actual thrown exception. It should contain a message or similar to give some context on what's the issue. It should be shown in vscode when debugging and printed to the console, if not caught and handled.

Sorry about that! I updated the original post to include that info.