[英]How to save a bearer token in front end from a url query string? RESTful api in ASP.NET
My application has local login and authentication in its WebAPI. 我的应用程序在其WebAPI中具有本地登录名和身份验证。 Regular login would save the bearer token in a session after verifying the users password and username client side. 常规登录将在验证用户密码和用户名客户端后将承载令牌保存在会话中。 I did so with axios. 我是用axios做到的。
Now i want a passwordless login for the users, by sending them a login link via email. 现在,我希望为用户提供无密码登录,方法是通过电子邮件向他们发送登录链接。 I have written code in my WEBapi that generates a Bearer Token for the user. 我已经在WEBapi中编写了为用户生成承载令牌的代码。 Ready to be sent and saved to a session. 准备发送并保存到会话中。
I am not sure what to do next. 我不确定下一步该怎么做。 I want my application to stay RESTful and not handle any sessions backend. 我希望我的应用程序保持RESTful状态,而不处理任何会话后端。
I could give the user a link with the Token as a query string. 我可以给用户一个带有令牌的链接作为查询字符串。 How can i write a front end script that would receive the token on load? 我如何编写前端脚本,该脚本将在加载时接收令牌?
What other solution are there? 还有什么其他解决方案?
编写一个在应用程序加载后立即触发的函数,并将查询字符串中的令牌存储在localStorage或sessionStorage或indexedDB中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.