When a user register to my web application I send an email to verify his inbox. In the email there are a link to a resource like this:
GET /verify/{token}
Since the resource is being updated behind the scenes, doesn't it break the RESTful approach?
How can I do it in a RESTful manner?
However, the best and quickest way to validate an email address is to use an email checker that looks at the address to see if it has the correct syntax and that mail can be delivered to the address.
The best and most recommended ways to verify an email address without sending an email are: Email verifier tools: Use an email verification service to check if the given address is valid or not. Just google 'Email Verifier,' and many free and paid options will come up.
Sign in to your email to verify your account While you're creating your account, you'll get an email from Google. Open the email and find the verification code. To finish creating your account, enter the verification code when prompted.
Email verification is the process of checking and authenticating emails that you've been given to ensure that they're authentic and that they're likely to connect you to a real person (or, at the least, a real email account of an organization).
What you are talking about is not REST. REST is for machine to machine communication and not for human to machine communication. You can develop a 1st party REST client, which sends the activation to the REST service.
You can use your verification URI in the browser to access the REST client:
# user follows a hyperlink in the browser manually
GET example.com/client/v1/verify/{token}
# asking the client to verify the token
and after that the REST client will get the hyperlink for verification from the REST service and send the POST to the service in the background.
# the REST client follows the hyperlinks given by the service automatically
# the REST client can run either on the HTTP client or server side
GET example.com/api/v1
# getting the starting page of the REST service
# getting the hyperlink for verification
POST example.com/api/v1/verification {token}
# following the verification hyperlink
If you have a server side 1st party REST client, then the HTTP requests to the REST service will run completely on the server and you won't see anything about it in the browser. If you have a client side REST client, then you can send the POST in the browser with AJAX CORS or you can try to POST directly with a HTML form (not recommended). Anyways the activation should be a POST or a PUT.
It depends on what are you trying to do.
Does it fire an email after validating the user for example? If so, it is not an idempotent method and you should use POST.
Example:
POST /users/{id}/verify/{token}
If the method doesn't have any consequence besides the update, I think you should use PUT.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With