Hi. I’ve been working with the GoTrue API using the GoTrue.js library you all provide. The docs and particularly the interactive API docs are very good, but there are some difficulties I had with the documentation that I thought it would be useful to clarify.:
Documentation on how to add user metadata when creating a user
Documentation of the secondary cookie attribute for methods that manage log in
Documentation on how to update user metadata when updating a user
No method or documentation (that I could find) for handling the update token sent when a user updates their email
To be clear, I was able to figure all these things out (except for the last one) but not without a lot of digging through code. Some things, like the cookie parameter, do appear in the readme but not the interactive example docs. Others, like addng/updating user metadata, I couldn’t find documented.
Just trying to make it easier on the next person Let me know if I can help with this effort.
I stepped away from the site I was going deep on Identity with for a while… let me see…
So based on what you wrote above it sounds like you’re fine with executing the update request, you’re just looking for how to handle the token in the URL in the email sent to the user to confirm their new email address. That URL will contain #email_change_token=ai-csfwfILRLUrVpA68a_w or the like.
The one key note about the email update token in particular is that the user has to have a JWT prior to clicking that link. E.g. they have to already be logged in. As long as that’s the case, and presuming that you’re using gotrue-js (per my assuming this is the CFE repo), you just have to run user.update() and specifically use the top level key email_change_token, so, with the above,