Skip to content

Is it possible to make requests "as" a particular user on the server? #1094

Answered by inian
churichard asked this question in Questions
Discussion options

You must be logged in to vote

Hi @churichard, yes you can do that. You need to generate a JWT with the sub claim as the user id and sign the JWT with your JWT secret of your project. Then you can pass that jwt into supabase-js like this.

const supabase = createClient(supabaseUrl, supabaseKey, {
  headers: {
    apiKey: anonKey,
    Authorisation: `Bearer ${jwt}`
  }
});

Replies: 4 comments 24 replies

Comment options

You must be logged in to vote
2 replies
@churichard
Comment options

@atnegrete
Comment options

Comment options

You must be logged in to vote
17 replies
@elanzini
Comment options

@csalmeida
Comment options

@bombillazo
Comment options

@Jonatthu
Comment options

@pierroo
Comment options

Answer selected by inian
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@lgtoledo
Comment options

@farzd
Comment options

@juanbercoff
Comment options

@juanbercoff
Comment options

@geoffreygarrett
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet