louis030195
03/09/2023, 1:42 PMpy
from typing import Tuple
import warnings
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
def enable_firebase_auth(app: FastAPI):
from firebase_admin import auth
@app.middleware("http")
async def firebase_auth(request: Request, call_next) -> Tuple[str, str]:
# extract token from header
for name, value in request.headers.items(): # type: bytes, bytes
print(name, value)
if name == "authorization":
authorization = value
break
else:
authorization = None
if not authorization:
return JSONResponse(
status_code=401, content={"error": "missing authorization header"}
)
s = authorization.split(" ")
if len(s) != 2:
return JSONResponse(
status_code=401, content={"error": "invalid authorization header"}
)
token_type, token = s
assert (
token_type == "Bearer"
), "Authorization header must be `Bearer` type. Like: `Bearer LONG_JWT`"
try:
token = token.strip()
decoded_token = auth.verify_id_token(token)
# add uid to scope
request.scope["uid"] = decoded_token["uid"]
except Exception as err:
warnings.warning(f"Error verifying token: {err}")
return JSONResponse(status_code=401, content={"error": "invalid token"})
response = await call_next(request)
return response
Whats the equivalent of auth.verify_id_token
in supabase?DwieDave
03/09/2023, 2:02 PMsetSession({access_token, refresh_token})
works in regard of setting the Session for requests authenticated as the logged in user.
But reading the docs setSession()
should also refresh a Session if it is expired.
But each time the JWT is expired and setSession()
is called with both tokens it returns the following error:
AuthApiError: Invalid Refresh Token
.
I did not call refreshSession()
or any other method using the refresh_token besides the setSession()
method.
I really don't have a clue if that is normal behavior.
Is the setSession()
function call with valid JWT invalidating the refresh_token?Zenon
03/09/2023, 2:10 PMRuben
03/09/2023, 2:24 PMLukas V
03/09/2023, 2:33 PMMonimolimnion
03/09/2023, 2:37 PMcategory_course
which consists of foreign keys linked to the category ids and course ids. So course 1 may be in category 1, course 2 in category 1, etc etc.
I want to retrieve all the Courses that belong to a given Category. I have the following query:
query Category($slug: String) {
categoriesCollection(filter: { slug: { eq: $slug } }) {
edges {
node {
id
name
category_courseCollection{
edges{
node {
courses {
name
}
}
}
}
}
}
}
}
But this returns {
"data": {
"categoriesCollection": {
"edges": [
{
"node": {
"id": "2",
"name": "Category Two",
"category_courseCollection": {
"edges": []
}
}
}
]
}
}
}
What am I doing wrong?EK
03/09/2023, 3:11 PMCharlesCharlieCharles
03/09/2023, 5:05 PMclifton
03/09/2023, 5:09 PMapp.supabase.com
, and it seems like my session expires like every few hours and I have to re-authenticate.
When I first started using hosted Supabase a couple months ago, it seems like a session would last a couple days.
Has anyone else noticed this? Or is it something wrong with my account?joshuabaker
03/09/2023, 5:13 PMpaulgo
03/09/2023, 6:04 PMThemeSupa
isn't a member of auth-ui-react
tsx
import { useUser, useSupabaseClient } from "@supabase/auth-helpers-react";
import { useRouter } from "next/router";
import { Auth, ThemeSupa } from '@supabase/auth-ui-react'<--- [PROBLEM]
import Link from "next/link";
export default function Login() {
//Supabase Database Handler
const supabaseClient = useSupabaseClient();
//User State from Supabase
const user = useUser();
//Next Router
const router = useRouter();
return (
<>
</>
)
}
th_m
03/09/2023, 6:09 PMconst value: SignInWithOAuthCredentials = {
provider:'facebook',
options: {
scopes:"public_profile, email",
},
};
supabaseClient?.auth.signInWithOAuth(value);
getting this error back in the URL
?error=server_error&error_description=Error+getting+user+email+from+external+provider#_=_?error=server_error&error_description=Error+getting+user+email+from+external+provider
Has anyone run into this? I have two test accounts i have been using. One is the account that owns the developer account, that one logs in no problem. The other is a typical user account and attempting to log in with that one returns the error.
I think it is a bug with the supabase auth sdk.
https://www.facebook.com/dialog/oauth?client_id=...&redirect_to=...&redirect_uri=...&response_type=code&scope=email+public_profile++email&state=...
It looks like email is already injected in there for us. but still not being added to the facebook dialog
sinsanelyok
03/09/2023, 6:58 PMffkml
03/09/2023, 7:01 PMjumeh
03/09/2023, 7:12 PMgtims123
03/09/2023, 7:25 PMArsi
03/09/2023, 7:36 PMinsanelyok
03/09/2023, 7:55 PMMindrest
03/09/2023, 8:06 PMmyChannel.unsubscribe()
supabase.client.removeChannel(myChannel)
myChannel = null
None of them work. I still have an instance of this channel. Any ideas of what am I doing wrong?
Here's the code snippet:
@override
void initState() {
_lobbyChannel = ref.read(chatRepositoryProvider).createChannel();
_lobbyChannel?.on(
RealtimeListenTypes.presence,
ChannelFilter(event: 'sync'),
(payload, [ref]) {
final presenceState = _lobbyChannel?.presenceState();
setState(() {
_usersOnline = presenceState?.values.length ?? 0;
});
debugPrint(
'On Sync: $_usersOnline - ${presenceState.toString()}',
);
},
).on(
RealtimeListenTypes.presence,
ChannelFilter(event: 'leave'),
(payload, [ref]) {
final presenceState = _lobbyChannel?.presenceState();
setState(() {
_usersOnline = presenceState?.values.length ?? 0;
});
debugPrint(
'On Leave: $_usersOnline - ${presenceState.toString()}',
);
},
);
super.initState();
}
@override
void dispose() {
if (_lobbyChannel != null) {
ref.read(chatRepositoryProvider).removeChannel(_lobbyChannel!);
}
super.dispose();
}
void joinSearch(String id) {
setState(() {
_isSearching = true;
});
_lobbyChannel?.subscribe(
(status, [ref]) async {
if (status == 'SUBSCRIBED') {
await _lobbyChannel?.track({'profile_id': id});
}
},
);
}
void stopSearch() {
setState(() {
_isSearching = false;
_lobbyChannel = null;
});
}
misakss
03/09/2023, 8:15 PMMATTI
03/09/2023, 8:21 PMdrewbie
03/09/2023, 8:51 PMjabza
03/09/2023, 9:32 PMjopfre
03/09/2023, 10:41 PMLuisfnicolau
03/09/2023, 10:45 PMgoldyman
03/09/2023, 11:28 PMStorageException(message: The resource was not found, statusCode: 404, error: Not found)
my policies for all actions are. I'm stuck and I don't know how to resolve this
dart
await _supabaseClient.storage.from('items').update(
'$userId/${insertedItem.id}.jpg',
itemFile,
fileOptions: const FileOptions(upsert: true),
);
Psygen
03/09/2023, 11:46 PMgaryaustin
03/10/2023, 1:10 AMJinni
03/10/2023, 1:35 AMZerro
03/10/2023, 1:54 AMjavascript
const {data, error} = await supabase
.from('<table name>')
.select('*', { count: 'exact', head: true })
Here, data returned is null. When I removed head (or set it to false), it returns data without any count as if I did not included the count option at all.
Maybe this is issue with getting count from Content-Range
in HEAD
request and that there is issue with Next 13 parsing the header?
javascript
export const createClient = () =>
createServerComponentSupabaseClient({
headers,
cookies,
})
Just curious if anyone else is having the same issue.