I'm trying to add different `metadata_admin` field...
# ory-network
r
I'm trying to add different
metadata_admin
field mappings from different social sign-in providers. Only the fields provided by the first provider that is linked (by the user) persist. Is this expected behaviour, and, if so, is there a workaround? For example, user first links Github as social login; then links Discord.
admin/identities/{id}
GET endpoint returns only metadata fields defined in the Github jsonnet mapping. Is there a way to populate fields from other providers, alongside the first one that is linked?
m
Hello Donatas, I am not sure if this is expected behaviour but it is the first time I come across it. Will see to ask the dev team early tomorrow for details. Is the field you want to populate through e.g. Discord already written by GitHub, so would it overwrite a value that already exists or is it a field that is empty and would just be written into by Discord?
gratitude thank you 1
r
Different (empty) fields, for example, the following two jsonnet mappings, for Discord and Github, respectively:
Copy code
local claims = {
  email_verified: false,
} + std.extVar('claims');

{
  identity: {
    traits: {
      [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email,
    },
    metadata_admin: {  
        discord_name: claims.name
	  },
  },
}
Copy code
local claims = {
  email_verified: false,
} + std.extVar('claims');
{
  identity: {
    traits: {
      [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email,
    },
    metadata_admin: {
      github_profile_url: claims.profile,
      github_avatar_url: claims.picture
    },
  },
}
m
And your identity schema has
Copy code
metadata_admin: {
      discord_name: string,
      github_profile_url: string,
      github_avatar_url: string
    },
?
r
I thought because metadata fields are not validated against the identity schema they don't need to be explicitly specified. Let me try that
The issue is still there, here's the identity schema and the result of
admin/identities/{id}
GET request for reference
Copy code
{
  "$id": "<https://schemas.ory.sh/presets/kratos/identity.email.schema.json>",
  "title": "Person",
  "type": "object",
  "properties": {
    "traits": {
      ...
    },
    "metadata_admin": {
      "type": "object",
      "properties": {
        "discord_name": {
          "type": "string"
        },
        "github_profile_url": {
          "type": "string"
        },
        "github_avatar_url": {
          "type": "string"
        }
      }
    }
  }
}
After linking github first:
Copy code
{
  "id": "e4477736-7129-487c-a737-984a3552b8ea",
  "credentials": {
    "oidc": {
      "type": "oidc",
      "identifiers": [
        "discord:927034984890523760",
        "github:33428886"
      ],
      "version": 0,
      "created_at": "2022-09-28T14:28:09.934526Z",
      "updated_at": "2022-09-28T14:28:50.394822Z"
    },
    "password": {
      ...
    },
    "webauthn": {
      ...
    }
  },
  "schema_id": "f17ab650e6caa0b4210e08c9b057fcbf9bc30f3ed270dea04e3048ada6295f746141bf1ce1ed60b633c874db2ea0e65a1524575a00fb579ef0c3f156587ffbb3",
  "schema_url": "<https://crazy-pascal-3unvbwebpl.projects.oryapis.com/schemas/ZjE3YWI2NTBlNmNhYTBiNDIxMGUwOGM5YjA1N2ZjYmY5YmMzMGYzZWQyNzBkZWEwNGUzMDQ4YWRhNjI5NWY3NDYxNDFiZjFjZTFlZDYwYjYzM2M4NzRkYjJlYTBlNjVhMTUyNDU3NWEwMGZiNTc5ZWYwYzNmMTU2NTg3ZmZiYjM>",
  "state": "active",
  "state_changed_at": "2022-09-28T14:28:09.813677Z",
  "traits": {
    ...
  },
  "verifiable_addresses": [
    {
      ...
    }
  ],
  "recovery_addresses": [
    ...
  ],
  "metadata_public": null,
  "metadata_admin": {
    "github_avatar_url": "<https://avatars.githubusercontent.com/u/33428886?v=4>",
    "github_profile_url": "<https://github.com/dotubutis>"
  },
  "created_at": "2022-09-28T14:28:09.837233Z",
  "updated_at": "2022-09-28T14:28:09.837233Z"
}
m
Hey Donatas, thanks for sharing your identity schema. I will do some investigation, but at this point I think this is expected behaviour (or rather a bug since you want multiple fields to be filled obviously). If I dont report back by end of the week, feel free to open a bug report (you can open one now also actually, but I still need to clarify this)
gratitude danke 1
r
I've opened a bug report https://github.com/ory/network/issues/164 🙂
🙌 1