Closed Carnageous closed 2 years ago
If it's okay, could you post the code snippet of the part where you got the error? Or the error itself?
Yeah sure, thanks!
At first I tried something like this:
connUrl := "http://" + user + ":" + password + "@" + host + ":" + port + "/" + dbName
client := postgrest.NewClient(connUrl, "public", nil)
res, err := client.From("my_table").Select("*", "", false).Execute()
if err != nil {
// I get an error from net/url: "invalid port \":myPassword after host"
panic(err)
}
fmt.Println(res)
But having the credentials in the URL did not seem to work (even when I did connUrl = url.QueryEscape(connUrl)
I got an error).
Then I tried to use the TokenAuth method like this:
client := postgrest.NewClient(connUrl, "public", nil)
client.TokenAuth("mySupabaseKey")
res, err := client.From("my_table").Select("*", "", false).Execute()
if err != nil {
// I get a net/url Error: "EOF"
panic(err)
}
using the API key I got from the supabase settings.
Does this look somewhat right to you
// Edit
I did find out in the meantime, that I have to use the /rest/v1
path for the connection string. Now I get something that looks like a connection timeout/error. Sorry for making this sound like a stack overflow page, I just wanted to ask for examples :D
Alright, so I was able to fix my problems! One of them was simply me doing mistakes (this is why I would love better docs), but I think I found two bugs as well?
No API key found in request
apikey
header to the request, next to the Authorization one. (It is stated in the supabase docs, that this is required):
solved it. I opened a PR for both fixes.Yes, there is some deficiency in the document part, I will complete those parts as soon as possible, I am also looking at the errors you sent. Thanks
I'm looking at the pr you sent
@muratmirgun There is still no example for the Auth on the README or at pkg.go.dev
I am thinking about using Supabase for multiple projects, but I have to integrate it with my own backend, so a documentation how to connect with Authentication would be really nice for people like me.
would also very much appreciate an auth example if this is possible
Hey! I love the idea behind this package, but have some troubles with getting started, as I am new to Supabase and PostgREST.
I would love to see some more examples on the usage of this package (with supabase), namely authentication.
client.TokenAuth
method?For anything I tried, I get some not-so-descriptive error (like just
EOF
from net/url) which is very likely because I did something wrong.All the examples I can find are just for a local setup without auth. Maybe adding a few more tests would be ideal for this? I would love to contribute once I used this a bit more.
I would greatly appreciate any help :)