Skip to content

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

Closed
@gibsorya

Description

@gibsorya

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions