<@U04UQ68083H> Do I have access to the traits when...
# ory-copilot
g
@chilly-king-10285 Do I have access to the traits when doing the data mapping jsonnet for oidc? I want to set the
passkey_identifier
to the same as
nickname
from the submitted form
b
A message from kapa.ai
Yes, you do have access to the traits when doing the data mapping with Jsonnet for OIDC. The traits are populated from the claims returned by the sign-in provider. You can map these claims to the traits as defined in the identity schema. Here is an example of a Jsonnet code snippet that maps the
nickname
claim to the
username
trait:
Copy code
jsonnet local claims = {     email_verified: false,   } + std.extVar('claims');      {     identity: {       traits: {         username: claims.nickname,       },     },   }
In this example,
claims.nickname
is the
nickname
claim returned by the sign-in provider. This value is mapped to the
username
trait in the Ory Identity schema. If you want to set the
passkey_identifier
to the same as
nickname
, you would replace
username
with
passkey_identifier
in the Jsonnet code snippet. Please note that you should not save secrets such as API keys, credentials, or personal data directly in Jsonnet code snippets. Jsonnet code snippets used for data mapping aren't stored in an encrypted format in Ory Network. For more information, you can refer to the following documentation: - [Salesforce Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/salesforce) - [GitHub Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/github#data-mapping) - [Auth0 Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/auth0) - [Ory API Reference](https://www.ory.sh/docs/reference/api) - [NetID Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/netid) - [Generic Provider Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/generic#additional-configuration) - [Google Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/google#additional-configuration) - [Microsoft Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/microsoft#additional-configuration)
g
How do I get the
username
or
nickname
field in the jsonnet?
@chilly-king-10285 How do I get the
username
or
nickname
field in the jsonnet?
b
A message from kapa.ai
In the Jsonnet code snippet for data mapping, you can access the
username
or
nickname
field from the claims returned by the sign-in provider. This is done using the
claims
object. Here is an example:
Copy code
jsonnet local claims = {     email_verified: false,   } + std.extVar('claims');      {     identity: {       traits: {         username: claims.nickname,       },     },   }
In this example,
claims.nickname
is the
nickname
claim returned by the sign-in provider. This value is mapped to the
username
trait in the Ory Identity schema. If the sign-in provider returns a
username
claim, you can access it with
claims.username
. Please note that the exact fields available in
claims
depend on the sign-in provider and the scopes you have requested. For more information, you can refer to the following documentation: - [Auth0 Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/auth0) - [Discord Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/discord) - [Salesforce Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/salesforce) - [Microsoft Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/microsoft#data-mapping) - [NetID Social Sign-in](https://www.ory.sh/docs/kratos/social-signin/netid)
g
@chilly-king-10285 I don't want a field from the claims, I want a field from the submitted form inputted by the user, such as
nickname
b
A message from kapa.ai
I'm sorry for the confusion, but based on the provided knowledge sources, it doesn't appear that you can directly access form data in the Jsonnet data mapping snippet. The Jsonnet data mapping is primarily used to map claims returned by the OIDC provider to the Ory Identity schema. However, the form data submitted by the user should be processed by Ory Kratos and the relevant fields (like
nickname
) should be part of the identity traits. If the
nickname
field is part of your identity schema, it should be available in the identity traits after the user registration or update process. If you need to perform custom logic based on the form data, you might want to consider using Ory Actions, which allow you to trigger custom logic based on various events in the Ory ecosystem. For more detailed guidance or to discuss your specific use case, I would recommend checking the [Ory documentation](https://www.ory.sh/docs) or reaching out to the Ory community.