Questions about Netlify Identity Serverless functions

Posted here: Migrating from Node and Express to the Jamstack - Part 2

I want to point out - while I greatly appreciate all your help, it would be truly nice if we could get an official Netlify support person to chime in. We’ve got multiple issues raised here, I’d also like to get a response to this post (Add additional social logon providers) too.

2 Likes

I’m with you there. I’m currently building a site implementing a lot of this auth / functions stuff, so hopefully we get more clarity there soon.
Perry oversees this community and is OOO this week and Dennis tends to lean more toward the Functions / Identity stuff AFAIK… between the two of them one should get back to us probably next week. Do remember that this is a free Community and supported by Netlify in kindness - this would be different if we were Enterprise tier users :stuck_out_tongue:

Thanks for your article, shout out, and general propensity to read my massive responses :grin:


Jon

1 Like

One of the comments I’ve made to an internal contact is that if the docs were on GitHub, I’d gladly make PRs for updates. While as a company, I do feel it is their job to document, I get a lot from Netlify and I’d be happy to “pay back” with doc edits. Especially since a lot of times we’re talking about little mods here and there to add context. I hope they consider letting external folks do that.

2 Likes

I’m with you there too haha :stuck_out_tongue: One step at a time :slight_smile:

1 Like

Since this is a serious documentation point, I thought I’d post this code example here (probably more to come) - didn’t end up using it, but here’s getting an array of all users from Identity in a Function. This was a few hours ago so I already forgot whether this is a paginated endpoint. Use this as a starting point and find out :slight_smile:

  exports.handler = async (event, context) => {

    const { identity } = context.clientContext
    const adminAuthHeader = 'Bearer ' + identity.token
    const usersUrl = `${identity.url}/admin/users`;

    const data = await fetch(usersUrl, {
      method: 'GET',
      headers: { Authorization: adminAuthHeader },
    }).then(res => res.json())

    const users = data.users
    const simplifiedUsers = users.reduce(
      (acc, cur) => {
        acc.push({ id: cur.id, email: cur.email, full_name: cur.user_metadata.full_name })
        return acc
      }, []
    )
    console.log(JSON.stringify(simplifiedUsers))

    // Do whatever you prefer at this point 👍🏻

    return {
      statusCode: 200
    }
  }
2 Likes