I’ve started using Identity service for my frontend. But I also have a CMS on back-end with users. I want to keep these user lists in sync, what would be the best approach for me to do that? I found that Netlify can send a webhook when some event happens in Identity service, but how can I use it on back-end? Should I somehow query Netlify for users? I didn’t found the API for Identity service. Thanks!
Hi @maxkoretskyi, you can get a list of your Identity users by creating a Netlify Lambda Function that does this: https://github.com/netlify/gotrue-js#get-a-list-of-users. You can invoke that with an Authorization header that contains an Identity user with an admin role.
Alternatively, you can set up a Netlify Lambda function that gets triggered by a signup (https://docs.netlify.com/functions/functions-and-identity/#trigger-serverless-functions-on-identity-events) that will perform some action against your backend.
Let me know if that helps.
Hey @Dennis, thanks a lot for your response!
Just to clarify a few things:
- With the first approach:
get a list of your Identity users by creating a Netlify Lambda Function that does this…
I can run this function to retrieve and return all users from Netlify’s Identity and then somehow trigger this function through Netlify’s API from my server to get the list?
- With the second approach
you can set up a Netlify Lambda function that gets triggered by a signup…
and then this lambda function can make a post request to update my remote server’s DB with the event data, correct?
- How do I run a Netlify Lambda Function on localhost for testing, particularly how to make authentication work? The
event
andcontext
parameters and correspondinglycontext.clientContext
I get here won’t be available:
exports.handler = async (event, context) => { ... }
Thanks!