Verify an email address
The /oauth/verify_email_native operation triggers the Registration system to send an email based on the configuration defined for the form used in the API call.
Email verification can also be initiated when a user registers (via /oauth/register_native_traditional.
1. Send verification email
$api_call= '/oauth/verify_email_native';
$params= array(
'client_id'=> JANRAIN_LOGIN_CLIENT_ID,
'flow'=> JANRAIN_FLOW_NAME,
'flow_version'=> JANRAIN_FLOW_VERSION,
'locale'=> 'en-US',
// page where the user is sent
'redirect_uri'=> EMAIL_VERIFICATION_URL,
// the name of your resend-verification form as defined in the flow file
'form'=> 'resendVerificationForm',
// required field from resendVerificationForm
'signInEmailAddress'=> $_POST['email']
);
$curl= curl_init();
curl_setopt($curl,CURLOPT_URL,JANRAIN_CAPTURE_URL.$api_call);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($params));
$api_response= json_decode(curl_exec($curl));
curl_close($curl);
Response | Outcome / Next Step |
---|---|
Success (ok) | Email verification email is sent to user. |
No account found for provided email address (invalid_credentials) | Provide a resolution path for this error. |
Email address already verified (triggered_error) | Provide a resolution path for this error. |
2. Retrieve the verification code
A successful oauth/verify_email_native call will send the email to the user which contains the verify_email_url appended with a verification code. The landing page for this link must parse the verification code and consume it via the /access/useVerificationCode API call.
3. Consume the verification code
curl -X POST
// verification code parsed from verify_email_url
--data-urlencode `verification_code=12345678912345678912345678912345` \
'https://my-app.janraincapture.com/access/useVerificationCode'
Response | Outcome / Next Step |
---|---|
Success (ok) | The Registration server automatically sets the timestamp on the user’s emailVerified attribute. |
Verification code not recognized (invalid_argument) | Provide a resolution path for this error. |
Updated almost 2 years ago