HTTP basic authentication URL with “@” in password

梦想的初衷 提交于 2019-12-20 10:19:05

问题


I'm trying to set up some selenium tests to our staging server using Sauce Labs. It's behind a basic http auth, so theoretically I could set the selenium URL to http://user:password@www.stagesite.com. However, the password contains a "@", causing all sorts of problems as you can imagine. I tried escaping it with a backslash but that did nothing from what I can tell.

So,

  1. is there an alternative way to do http authentication using selenium, i.e., not via the URL. Or,

  2. is there a way to use URL-based auth but somehow tell the browser that the "@" is part of the password?


回答1:


You just need to encode special characters like that before passing them as part of the URL, so @ would need to be passed as %40, etc.

(I typically use this - http://meyerweb.com/eric/tools/dencoder/ - for my en/decoding needs.)



来源:https://stackoverflow.com/questions/20574841/http-basic-authentication-url-with-in-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!