最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Unable to implement OTP with Web OTP API - Stack Overflow

programmeradmin8浏览0评论

Web OTP API information provided by /web-otp is good. But demo provided in / is working as of now with Version 86.0.4240.111 (Official Build) (64-bit).

The main reason I could see is that navigation credentials event for OTP is not getting triggered, and I don't understand why this is happening.

Is it problem with codebase of / OR chrome mentioned version has any problem?

Steps to reproduce -

  1. Open / at your mobile browser.
  2. As webpage says, get @web-otp.glitch.me #12345 as text message to your mobile, from unknown number . And you should receive a dialog message, asking you whether you want your browser to input this OTP.

Web OTP API information provided by https://web.dev/web-otp is good. But demo provided in https://web-otp.glitch.me/ is working as of now with Version 86.0.4240.111 (Official Build) (64-bit).

The main reason I could see is that navigation credentials event for OTP is not getting triggered, and I don't understand why this is happening.

Is it problem with codebase of https://web-otp.glitch.me/ OR chrome mentioned version has any problem?

Steps to reproduce -

  1. Open https://web-otp.glitch.me/ at your mobile browser.
  2. As webpage says, get @web-otp.glitch.me #12345 as text message to your mobile, from unknown number . And you should receive a dialog message, asking you whether you want your browser to input this OTP.
Share Improve this question edited Dec 17, 2024 at 8:17 VLAZ 29.2k9 gold badges63 silver badges85 bronze badges asked Nov 3, 2020 at 5:58 Vaibhav AroraVaibhav Arora 942 silver badges9 bronze badges 10
  • The code provided in the links are correct, but you need some network carrier to send you SMS of OTP. Also, try using in a mobile browser(or change to a mobile device using the toggle in chrome). And read this answer stackoverflow./a/59150919/11926970 – Not A Robot Commented Nov 3, 2020 at 6:04
  • I checked the feature. I tried on mobike only, I sent myself code from contacts and unknown number. I am experienced developer, and I debugged the code too. I am stating the event of navigator.credentials.get() for OTP is not getting trigged when an OTP is recieved. Can you check at your end and confirm me if issue exists at your end too? Because then I will report it to Chrome team – Vaibhav Arora Commented Nov 4, 2020 at 2:50
  • Can you update the question with the code you wrote and all the steps to reproduce the result? – Not A Robot Commented Nov 4, 2020 at 3:53
  • Done stackoverflow./users/11926970/not-a-bot – Vaibhav Arora Commented Nov 4, 2020 at 10:42
  • anybody else wants to try? – Vaibhav Arora Commented Nov 10, 2020 at 14:46
 |  Show 5 more ments

3 Answers 3

Reset to default 4

Try changing the host name, incorrect host name may stop the Promise from getting resolved, i.e., navigator.credentials.get

Make sure your last line of text message should be like this:

@<HOSTNAME_OF_WEBSITE> #<OTP>

After some experimenting it only seemed to work if the last line with text before the last line (with the @ and #) ended in numbers.

Really weird.

So its like:

OTP code: <OTP>

Ignore this: 1111

@<HOSTNAME_OF_WEBSITE> #<OTP>

The hostname must match the one where the input form lives. If the input form is on a subdomain then that must be your hostname. The @hostname must start on a new line followed by exactly 1 space, and "#" and then your code.

Everything before or after is ignored. So you should on the start of the message use a more user friendly code, in case the OTP auto fill fails, the user can still understand and type manually.

there is a chance to use a iframe with the input verification, check the WEB OTP documentation for that special case.

发布评论

评论列表(0)

  1. 暂无评论