You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A clear and concise description of what the bug is.
To Reproduce
import { serve } from 'https://deno.land/[email protected]/http/server.ts'
import { createClient } from 'https://esm.sh/@supabase/[email protected]'
import { corsHeaders } from '../_shared/cors.ts'
console.log(`Function "user-self-deletion" up and running!`)
serve(async (req: Request) => {
// This is needed if you're planning to invoke your function from a browser.
if (req.method === 'OPTIONS') {
return new Response('ok', { headers: corsHeaders })
}
try {
const authorization = req.headers.get('Authorization');
if (!authorization) {
return new Response(JSON.stringify({ error: "No authorization header passed" }),
{ status: 500, headers: { 'Content-Type': 'application/json' }, });
}
// Create a Supabase client with the Auth context of the logged in user.
const supabaseClient = createClient(
// Supabase API URL - env var exported by default.
Deno.env.get('SUPABASE_URL') ?? '',
// Supabase API ANON KEY - env var exported by default.
Deno.env.get('SUPABASE_ANON_KEY') ?? '',
// Create client with Auth context of the user that called the function.
// This way your row-level-security (RLS) policies are applied.
{ global: { headers: { Authorization: req.headers.get('Authorization')! } } }
)
// const user_id =await supabaseClient.auth.getUser(authorization)
// Get JWT from auth header
const jwt = authorization.replace("Bearer ", "");
// Get the user object
const { data: { user },} = await supabaseClient.auth.getUser(jwt);
Bug report
Created an Edge Function for user-self-deletion but when I create the supabaseClient and try to getUser(jwt) I recieve this error
code: "bad_jwt"
name: "AuthApiError"
status: 403
__isAuthError: true
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Expected behavior
I want to know why I'm getting this error.
Screenshots
System information
[email protected]
Additional context
The text was updated successfully, but these errors were encountered: