Skip to content

Auth is not intialised with User Token #16

@hemanth-gopi

Description

@hemanth-gopi

Auth is not initialised with User Token

Whenever you create a new Client using supabase.NewClient() and by passing custom headers with the Authorisation token, the Auth field is not initialized with the same token.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Initialize the supabase Client as follows with the user token

headers := map[string]string{
	"Authorization": token,
}

clientOptions := supabase.ClientOptions{
	Headers: headers,
	Schema:  "custom_schema",
}

client, err := supabase.NewClient(supabaseApiUrl, supabaseAnonKey, &clientOptions)

Now when you want to access the User object, you intend to use the following snippet
user, err := client.Auth.GetUser()

But this will lead to the following error

"msg":"error getting user",
"error":"response status code 401: 
{
    \"code\":401,
    \"error_code\":\"no_authorization\",
    \"msg\":\"This endpoint requires a Bearer token\"
}

Expected behavior

A user object should be obtained with user details using the token passed during initialization of superbase client

System information

  • OS: [e.g. Windows]

  • github.com/supabase-community/functions-go v0.0.0-20220927045802-22373e6cb51d // indirect

  • github.com/supabase-community/gotrue-go v1.2.0 // indirect

  • github.com/supabase-community/postgrest-go v0.0.11 // indirect

  • github.com/supabase-community/storage-go v0.7.0 // indirect

  • github.com/supabase-community/supabase-go v0.0.4 // indirect

Additional context

Add any other context about the problem here.

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