简体   繁体   English

如何将用户信息从服务器传递到Chrome扩展的网页?

[英]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: 这是顺序:

  1. say cnn.com (on login button click) 说cnn.com(在登录按钮上单击)
  2. [my Backend] /authenticate is called [我的后端] / authenticate被称为
  3. (supported service) login page is displayed 显示(支持的服务)登录页面
  4. [my Backend] /callback is called [我的后端] / callback被调用
  5. redirect to cnn.com on success 成功重定向到cnn.com

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.

相关问题 无法将邮件从网页传递到Chrome扩展程序 - Cannot pass messages from Webpage to Chrome Extension 将数据从Chrome扩展程序传递到网页 - Pass data from chrome extension to webpage 将消息从 Chrome 扩展程序传递到网页 - Pass a message from Chrome Extension to Webpage 尽快将变量从chrome扩展程序传递到网页 - Pass variable to webpage from chrome extension as soon as possible 如何将数据从网页传递到chrome ext? - How pass data from webpage to chrome ext? 已解决:将经过身份验证的用户的 email 从网页发送到 chrome 扩展程序 - SOLVED: Sending authenticated user's email from webpage to chrome extension Chrome扩展程序-如何获取从网页调用的POST请求用户的响应? - Chrome extension - how to get response of POST request user invoked from a webpage? 如何在Google Chrome扩展程序中将信息从Background.js传递到autofill.js? - How can I pass information from Background.js to autofill.js in my Google Chrome extension? 如何通过将侦听器添加到“窗口”来从Chrome扩展程序单击网页上的按钮? - How to click a button on a webpage from Chrome extension by adding a listener to `window`? Chrome扩展程序:如何修改从网页中的Ajax请求创建的元素? - Chrome extension: How to modify elements created from an Ajax request in a webpage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM