DEV Community

Discussion on: Using Clerk to authenticate users in a Go backend

Collapse
 
fmerian profile image
fmerian • Edited

thanks for this tutorial, @marcuskohlberg! we just featured it on our latest product update here πŸ™Œ

fun fact: Clerk's backends are written in Go and the backend that powers our Dashboard experience is a heavy consumer of our open-source Clerk Go SDK!

Collapse
 
marcuskohlberg profile image
Marcus Kohlberg Encore

Awesome, thanks for sharing!

Collapse
 
ceaser_ak profile image
ceaser

hey @fmerian how do you handler data sync from clerk to the database in golang via webhooks? there aren't many good resources out there which explains this, couldn't find a go example in official repo as well.

Collapse
 
brianmmdev profile image
Brian Morrison II

Give this a look and let me know if you have any questions!

github.com/bmorrisondev/clerk-go-w...

It shows how to parse the user.created and organization.created events into Go structs so you can handle them however you need. You'd need to create the structs for any other events you want to parse, but you can do this pretty easily with ChatGPT and the samples provided in the Webhooks section of our dashboard.

I'm going to push to get something more official but this should at least get you going. Hope it helps!

Collapse
 
fmerian profile image
fmerian
Thread Thread
 
ceaser_ak profile image
ceaser

@brianmmdev ^^ , would love to get a proper official go guide on this

Thread Thread
 
brianmmdev profile image
Brian Morrison II

Hey there! I'll get working on a demo to share! In the meantime, I do have some resources that might help move you in the right direction before I can spin up a more official guide.

I wrote for the PlanetScale blog a while back about receiving webhooks with Go: planetscale.com/blog/sync-user-dat...

Downside is I did not actually verify the webhook (which I sorely regret now πŸ˜…). Luckily, this guide shows how to do just that: svix.com/guides/receiving/receive-...

I'll be out of town this coming week but will do my best to get a functional example working!

Thread Thread
 
ceaser_ak profile image
ceaser

Thanks Brian, the code demo helped a lot!

Thread Thread
 
fmerian profile image
fmerian

@brianmmdev is the 🐐