I assume you want to have someone sign in with a principal, and not verify if a printed principal is a valid principal.
The way to do this is to generate a challenge that the user then signs with their identity. On the backend, you can then verify the signature(s) and timestamps. I do not have code ready to copy/paste, but there is probably a lot you can copy from this crate