我需要通过 GET 调用访问数据,但资源受单点登录保护。我有 URI 端点和单点登录凭据。我开始使用 XMLHttpRequest() 发出 ajax 请求,但得到了这个:
被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头。
由于我无权访问服务器,因此无法将“Access-Control-Allow-Origin”设置为 true,因此我决定转而使用带有 Flask 后端的 Python 请求库进行调用。我尝试将用户凭据与 GET 请求一起传递,如下所示:
headers = {'accept': 'application/json;odata=verbose'}
r = requests.get(url, auth=HTTPBasicAuth(userid, password), headers=headers)
print r.status_code #prints 403
print r.content #prints 403 forbidden
Run Code Online (Sandbox Code Playgroud)
有没有办法访问这样的资源?请注意,SSO 是使用 SAML 2.0 配置的
更新: 跟踪 giaco 建议的链接后,我现在可以以编程方式登录到 SSO。至少,我认为是这样..(s.post(..) 返回的 HTML 实际上仍然有 403 禁止代码——但是当我在浏览器中点击 url 时,它重定向到登录页面)但是,当我发送 GET请求,我再次收到 403 FORBIDDEN 消息。以下是更新后的代码:
payload = {
'UserName': username,
'Password': password
}
print "configured payload" #successfully printed on console
with requests.Session() as s:
p …Run Code Online (Sandbox Code Playgroud) 是否有人可以在gcc版本问题上给初学者一些帮助?
我在遇到了这个问题"version GLIBCXX_3.4.20' not found"。在我链接之后:如何在CentOS 7.2上用yum安装gcc 5.3?
我遇到了以下额外问题:
scl enable devtoolset-7 bash
git: relocation error: libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
Run Code Online (Sandbox Code Playgroud) I have a vagrant-box running CentOS6.7 on which I am running docker containers. I intend to run flask applications served by nginx inside the container. I had to make certain changes inside the nginx.conf file to serve my application (app1) by nginx. This may seem a little strange, but I am not able to change nginx.conf file inside /etc/nginx/conf.d/nginx.conf
Here is what I did:
My Dockerfile looks like this:
FROM tiangolo/uwsgi-nginx-flask:flask
COPY ./app /app
COPY ./changes/nginx.conf …Run Code Online (Sandbox Code Playgroud)