hey team, when I use google (haven't tried other p...
# talk-kratos
s
hey team, when I use google (haven't tried other providers) to create an account, I get the following identity ID back
00000000-0000-0000-0000-000000000000
When I create an account using a password, I get a proper ID back. I use this ID in another DB to link to this user. Did I miss something while setting up google OIDC?
or this ID is the default
sub
provided by google when it is in test mode?
but I see that it's give a proper id when I retrieve the identity from the kratos API. How can I get the correct ID when using a hook, when creating the account?
w
It's zero when it's a pre persist hook, a hook executed before persisting / creating the entity, this is the case when you use can_interrupt or parse
This used to be different in an older version and unfortunately is considered as a bug. It is reported on GitHub as well as multiple times on Slack here
s
oh, I see. Thanks for the update. I store the created user in another DB before creating the entity, with the hook.
w
Yes, unfortunately you can't get the entity ID there
s
Thanks anyway!
Cheers
w
What you could do is do two hooks, the one you have and one without can interrupt / parse that runs after persisting the entity and merges the entity ID in your internal record
s
good one. i'll try that
coming back to this, is there any estimate when this gonna be fixed? I cannot update the ID after it's set. I can achieve what I need without the
can_interrupt
for now, but with this, the user will be created even if the hook fail, which is not optimal.
and I cannot create the entity with the zero value ID, because I cannot change this ID later.
d
I’ve just implemented the same thing using 2 hooks - one creates an entry in our database, and returns
Copy code
{
  identity: {
    public_metadata: {
      memberId: WHATEVER
  }
}
which gets written to kratos. The second webhook then has the kratos identity ID and we update our database with that. I’m not sure it’s possible to do it another way - one of the webhooks is called before the identity is written to the database, and so the ID does not exist yet
s
In my case I don't have this option, I cannot alter the ID after is set.
d
we have a primary ID in our database, and a separate kratosId row to store the Kratos ID so we can do the mapping