简体   繁体   中英

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. 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)
  2. [my Backend] /authenticate is called
  3. (supported service) login page is displayed
  4. [my Backend] /callback is called
  5. redirect to cnn.com on success

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

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.

Chrome extensions allow you to access cookies on any domain you'd like, as long as you specify the correct permissions on your manifest.

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. Remember to use chrome.cookies.get() / getAll() instead of document.cookie to properly access cookie data across domains.

您是否有理由不能使用现有的身份验证方案,例如SAML

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM