'How to force a re-authentication of the proxy in a Chrome/Firefox extension / Change session ID inside username?
It is common practice for proxy companies to use session IDs inside the proxy user credential string to provide session control and keep the same IP for multiple requests or quickly change it.
Quick example using an Oxylabs proxy: Full Proxy String: “pr.oxylabs.io:7777:customer-USERNAME-sessid-randomString123:PASSWORD”
Host and port are static: “pr.oxylabs.io:7777”
The proxy user credentials are dynamic: “customer-USERNAME-sessid-randomString123:PASSWORD”
Switching the “randomString123” in front of the “sessid” changes your session and with that also your IP.
Now here comes the problem with using these proxy sessions inside a Chrome/Firefox extension:
Once you set your proxy and submit your user credentials, Chrome & Firefox will save your user credentials (and with that your session ID & IP) for that proxy host and keeps using them. But I want to change my session for that host.
How do we force a re-authentication of the proxy so we can submit a new username and switch our session/IP?
I wasn't able to find a single proper solution for this yet but here is everything that I found so far:
(Works on Firefox and Chrome) Set your proxy again with a slightly modified host. “pr.oxylabs.io" -> “pr.oxylabs.io." (Putting a dot at the very end). I don't think many modifications here are possible though and Chrome will save your credentials for each one of them again. Do you know any other methods of modifying the host without stopping it to work? Please let me know.
(Only works on Chrome) Delete all cookies of a domain or delete your password data via "chrome.browsingData.removePassword". Deleting cookies ruins the user experience. Deleting password data cancels all currently ongoing network requests and bugs out websites. Both aren't good solutions.
I read about this one and also found it inside the Oxylabs proxy extension but it didn't work for me. It's restarting the "chrome.webRequest.onAuthRequired" listener. If you know more about this please let me know.
Firefox also lets you pass a "proxyAuthorizationHeader" string when setting a proxy (Example: Basic dXNlcm5hbWU6cGFzc3dvcmQ=). But it only lets you do that for "https" proxies but not "http" proxies (throws the error "ProxyInfoData: ProxyAuthorizationHeader requires type "https""). Do you know a way to make this work for "http" proxies too? Please let me know.
In summary, a solution to one of the questions below would solve my issue:
- How do we force a re-authentication of the proxy so we can submit a new username and switch our session/IP?
- Are there more methods (other than one dot at the end) of modifying the host without stopping it to work?
- Is there a way to use the ProxyAuthorizationHeader string of proxy objects in Firefox for http proxies?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
