[英]How to pass user information from server to webpage for a chrome extension?
I am building a chrome extension that would insert a login button on a webpage. 我正在构建一个Chrome扩展程序,该扩展程序将在网页上插入一个登录按钮。 When users click on the button, they will be directed to a login page and then redirected back.
当用户单击按钮时,他们将被定向到登录页面,然后将其重定向回。 I would like to pass information during redirection.
我想在重定向期间传递信息。
Here is the sequence: 这是顺序:
I don't know how to pass the "user" info to the page or the extension on redirect, during this step [my Backend] /callback > redirect to xyz.com
在此步骤
[my Backend] /callback > redirect to xyz.com
过程中,我不知道如何将“用户”信息传递给页面或扩展名
I am inserting the button using content script. 我正在使用内容脚本插入按钮。 I am trying to find ways to send user info to the extension during redirection and store it for later use.
我正在尝试找到在重定向期间将用户信息发送到扩展并将其存储以供以后使用的方法。
You can store the state of the user, and whether or not they should be logged in on a cookie on your own domain. 您可以存储用户的状态,以及是否应使用您自己域上的cookie登录他们。
Chrome extensions allow you to access cookies on any domain you'd like, as long as you specify the correct permissions on your manifest. 只要您在清单上指定正确的权限,Chrome扩展程序就可以让您访问任何域上的Cookie。
Then, you can use the chrome.cookies API in order to access cookies on your own domain, even if your Chrome extension is running on a different web page. 然后,即使您的Chrome扩展程序在其他网页上运行,也可以使用chrome.cookies API来访问您自己域上的cookie。 Remember to use
chrome.cookies.get() / getAll()
instead of document.cookie
to properly access cookie data across domains. 记住要使用
chrome.cookies.get() / getAll()
而不是document.cookie
来跨域正确访问cookie数据。
您是否有理由不能使用现有的身份验证方案,例如SAML ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.