メインコンテンツへスキップ
ネイティブアプリケーションで埋め込み型パスワードレスAPIを使用するには、[Auth0 Dashboard]>[Applications(アプリケーション)]>[Applications(アプリケーション)]に移動して、アプリケーション設定の [Advanced Settings(高度な設定] > [Grant Types(付与タイプ)] OTP(パスワードレスOTP)] の付与を有効にしなければなりません。 ネイティブアプリケーションのパスワードレス認証は、2つのステップで構成されています。
  • アプリケーションでユーザーIDを取得し(ユーザーのメールまたは電話番号)、/passwordless/startエンドポイントを呼び出し、パスワードレスフローを開始します。ユーザーは、一回限り使用できるパスワードが記載されたメール、またはSMSを受け取ります。
  • 1回限り使用できるコードをユーザーに要求し、認証トークンを取得するために/oauth/tokenエンドポイントを呼び出します。
以下に、様々なシナリオに対して、これらのAPIエンドポイントを呼び出すために使用できるコードスニペットをいくつか挙げます。 メールで一回限り使用できるパスワードを送信する
curl --request POST \
  --url 'https://{yourDomain}/passwordless/start' \
  --header 'content-type: application/json' \
  --data '{"client_id": "{yourClientId}",  "connection": "email",   "email": "USER_EMAIL",  "send": "code"}'
メールでマジックリンクを送信する
curl --request POST \
  --url 'https://{yourDomain}/passwordless/start' \
  --header 'content-type: application/json' \
  --data '{ "client_id": "{yourClientId}", "connection": "email", "email": "USER_EMAIL", "send": "link"}'
SMSで一回限り使用できるパスワードを送信する
curl --request POST \
  --url 'https://{yourDomain}/passwordless/start' \
  --header 'content-type: application/json' \
  --data '{ "client_id": "{yourClientId}",  "connection": "sms",  "phone_number": "USER_PHONE_NUMBER", "send": "code"}'
SMSユーザーを認証する
curl --request POST \
  --url 'https://{yourDomain}/oauth/token' \
  --header 'content-type: application/json' \
  --data '{ "grant_type": "http://auth0.com/oauth/grant-type/passwordless/otp",  "client_id": "{yourClientId}",  "username": "USER_PHONE_NUMBER",  "otp": "code",  "realm": "sms", "audience": "your-api-audience", "scope": "openid profile email"}'
メールユーザーを認証する
curl --request POST \
  --url 'https://{yourDomain}/oauth/token' \
  --header 'content-type: application/json' \
  --data '{"grant_type": "http://auth0.com/oauth/grant-type/passwordless/otp", "client_id": "{yourClientId}", "username": "USER_EMAIL", "otp": "code", "realm": "email", "audience": "your-api-audience", "scope": "openid profile email"}'
必要であれば、これらのAPIをプラットフォームに適した方法でラップするAndroidまたはiOSのSDKを使用できます。
I