Hi ORY team, *If this is not the correct place or ...
# ory-selfhosting
c
Hi ORY team, If this is not the correct place or format please let me know. I'm setting up authentication using self-hosted Ory Kratos (v1.3.1) and Hydra (v2.2.0). My goal is a login flow where the user's phone number is their username, and the OTP code is sent to their email. The flow is: 1. User registers with phone and email
Copy code
kratosAdminClient.createIdentity({
      createIdentityBody: {
        schema_id: 'default',
        traits: {
          phone: phone,
          email: email
        }
      }
    })
1. User starts OIDC login (PKCE) (
/oauth2/auth?...
) → gets
login_challenge
2. User gets login UI with
login_challenge
3. User submits phone number → OTP code sent to email 4. User verifies OTP code 5. Consent UI + accept 6.
/oauth2/token?...
At step 4, I get the error: "account does not exist or has not setup up sign in with code" Here are the relevant parts of my configuration: kratos.yml
Copy code
...
identity:
  default_schema_id: default
  schemas:
    - id: default
      url: file:///etc/config/kratos/identity.schema.json
...
selfservice:
  methods:
    code:
      enabled: true
      passwordless_enabled: true
      config:
        lifespan: 15m
...
identity.schema.json
Copy code
{
  "$id": "<https://example.com/registration.schema.json>",
  "$schema": "<http://json-schema.org/draft-07/schema#>",
  "title": "Person",
  "type": "object",
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "title": "E-Mail",
          "<http://ory.sh/kratos|ory.sh/kratos>": {
            "recovery": {
              "via": "email"
            },
            "verification": {
              "via": "email"
            }
          }
        },
        "phone": {
          "type": "string",
          "title": "Phone",
          "format": "tel",
          "minLength": 3,
          "<http://ory.sh/kratos|ory.sh/kratos>": {
            "credentials": {
              "code": {
                "identifier": true,
                "via": "email"
              }
            }
          }
        }
      },
      "required": [
        "phone",
        "email"
      ],
      "additionalProperties": false
    }
  }
}
Hydra client registration
Copy code
curl -X POST <http://localhost:4445/admin/clients> \
  -H "Content-Type: application/json" \
  -d '{
    "client_id": "<http://my.client.app|my.client.app>",
    "grant_types": ["authorization_code", "refresh_token"],
    "response_types": ["code"],
    "scope": "openid offline",
    "redirect_uris": ["<my.client.app://oauth2redirect>", "<http://localhost:8089/callback>"],
    "token_endpoint_auth_method": "none"
  }'
Could you help me understand what I might be missing in my setup or configuration? Thanks
m
Hey Matthew, Thanks for the detailed description and config. The error means either the identity with the provided phone number does not exist, or the
phone
trait is not properly configured as a code login identifier. some quick debugging tips: • Make sure the trait is named exactly
phone
in both the schema and when creating the identity. The value must match exactly (including formatting) between registration and login. • If you changed the schema after starting Kratos, make sure to reload or restart the service. • Confirm that the
code
method is enabled and
passwordless_enabled: true
in your config. • Make sure the login UI or API is sending the
phone
value as the identifier for the code login flow.
c
Vincent thank you for the reply. I have been debugging this some. Here are some answers to your tips. • Make sure the trait is named exactly
phone
in both the schema and when creating the identity. The value must match exactly (including formatting) between registration and login. ◦ so in my schema it "phone" with a title of "Phone". ◦ Does the title matter? ◦ For the create Part I am going dig even deeper but right now the payload I am passing is { schema_id: 'default', traits: { phone: PHONENUMBER, email: EMAILADDRESS } • If you changed the schema after starting Kratos, make sure to reload or restart the service. ◦ I am using docker and have double check this to be sure • Confirm that the
code
method is enabled and
passwordless_enabled: true
in your config. ◦ Based on my kratos.yml file those both should be correct with and addition config of lifespan: 15m. ◦ I can share my entire Kratos.yml file if need be to make sure I don't have something conflicting? • Make sure the login UI or API is sending the
phone
value as the identifier for the code login flow. ◦ here is the payload I current pass. { flow: flowId, updateLoginFlowBody: { method: 'code', identifier: phone, csrf_token: csrfToken } }
@magnificent-energy-493 is it better to post my responses here or should I craft a post in github with all the information?