- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在发布这个问题之前,我已经完成了大部分堆栈溢出问题,但我没有得到答案
我正在尝试访问一个将执行 Oauth 身份验证的客户端 api,因此当我调用该 api 时,它应该抛出一个弹出窗口以进行类似于 fb auth 的身份验证,但我最终在我的 chrome 控制台中出现错误,如下所示
XMLHttpRequest cannot load https://api.springrole.com/authorize?
scope=XXXX&redirect_uri=http://localhost:8080/CheckRest/springrole.html&response_type=XXXX&client_id=XXXXXXXX. The request was redirected to 'https://springrole.com/site/login?api_login=1&scope=XXXX&state=&error=invalid_request', which is disallowed for cross-origin requests that require preflight.
为了安全起见,我刚刚用 XXX 屏蔽了一些值。我的请求如下所示
$http({
method : 'GET',
url : url,
headers : {
'Content-Type' : 'application/json',
"Access-Control-Allow-Origin": "https://api.springrole.com",
"Access-Control-Allow-Methods":"GET",
"Access-Control-Allow-Credentials": true
}
}).success(function(data, status, headers, config) {
$scope.details.response = JSON.stringify(data);
console.log("success" + data)
})
如果我删除请求中的 header ,我会收到下面显示的错误
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
任何建议或解决方法将不胜感激。
最佳答案
是的,您遇到了 Same Origin Policy这是出于安全原因。简而言之,基本上你是在请求/打开来自不同来源的东西,这不是很安全。如果需要,您可以通过添加参数 --disable-web-security
在 Chrome 中暂时禁用它。
所以你可以从终端运行
open -a Google\Chrome --args --disable-web-security
我经常这样做,所以我最后只是在我的 .bash_profile
中添加别名,这样我就可以轻松访问它
# Run Insecure Chrome
alias insecure-chrome='open -a Google\ Chrome --args --disable-web-security'
然后在终端中我只需调用 insecure-chrome
Chrome 就会弹出。如果您在顶部看到安全警告,您就会知道它有效。警告看起来像这样
当然,在执行此操作时必须小心警告。我不会以这种模式上网,但在本地工作应该没问题。
对于 Windows 用户,您可以导航到安装和设置 Chrome 的文件夹
chrome.exe --user-data-dir="C:/temp" --disable-web-security
确保在执行此操作之前关闭所有 Chrome 实例,否则它将无法工作。
关于angularjs - 请求被重定向到 'https://..com/site/login?' ,这对于需要预检的跨源请求是不允许的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28036696/
嗨,我试图在亚马逊服务托管的计算机上远程登录。这是ubuntu 64位机器。 一开始,我能够使用客户端、远程桌面连接 (RDP) 登录计算机,并保持默认端口 (-1),而对于命令行,我使用 putty
我已将 Jenkins 设置为使用 Unix 用户/组数据库安全性,但除了运行 Jenkins 服务的用户之外,我无法使用我创建的任何用户登录。通过 ssh 或 su 登录服务器可以工作,但是当我尝试
我想通过 power shell 使用以下命令在 azure 中创建一个新的资源组: New-AzureRmResourceGroup - Name name -Location "WesternEu
我已经部署了由 spring boot 应用程序使用 oauth2 生成的 war 文件,以便使用 Azure 应用服务进行单点登录(仅限 https)。 当我浏览主页时,主页会加载一个登录按钮。单击
我已经部署了由 spring boot 应用程序使用 oauth2 生成的 war 文件,以便使用 Azure 应用服务进行单点登录(仅限 https)。 当我浏览主页时,主页会加载一个登录按钮。单击
我尝试按照一些 django 教程来创建登录名,但我一直在获取 ImportError at /login No module named login 我的文件结构是: -src -log
在我的 Spring 项目中,我将注销目标 url 设置为“/login?logout”以显示登录页面并显示消息“您现在已注销”。 在 Spring Security 配置中,我这样做了: @Over
我目前正在尝试为我在带有 Ubuntu 的虚拟机上运行的实际本地网页创建一个简单的登录页面。 我创建了 LoginPage.html在位置 /var/www/html . 然后 HTML 文件调用 l
我有两个安全区域,我为其提供基于表单的登录。 /用户 /admin 以下按预期工作: 访问 protected 资源时重定向到登录页面 当凭据为假时使用 ?error 参数重定向到登录页面 根据定义的
我有一个脚本,我通常用来同步AG登录。但是,我需要使用SQL凭据和密码将其实现为自动运行。有人知道我如何调整下面的脚本以使用SQL登录和密码吗?
更新 下面的 Flask 重定向(响应代码 302)似乎作为对 _dash-update-component 的响应传递。要求: b'\nRedirecting...\nRedirecting...\
这是我第一次使用 Django 登录模板,但遇到了问题。它一直说 login 不是一个有效的 View 函数,但我在我的用户应用程序的 urls.py 中定义了它: 不知道我做错了什么。 主 urls
我不是专业程序员,所以请原谅任何愚蠢的错误——我正在做一些研究,我正在尝试使用 Selenium 登录数据库以搜索大约 1000 个术语。 我有两个问题:1. 重定向到组织登录页面后如何使用 Sele
我正在使用 flutter,我想在我的应用程序中实现使用 Instagram 登录。所以我关注这个tutorial用于 Instagram 登录, 我成功登录但未获取用户详细信息,它正在打开重定向 U
每当我以访客身份重定向时,我都会收到错误消息: Missing required parameters for [Route: login] [URI: {locale}/login]. 但是当我登录
我已开始使用 Azure Pipelines 和 GitHub 支持的帐户并创建了我的第一个组织。我在该组织中没有任何项目。我在 portal.azure.com 上也没有任何订阅。我想使用 Azur
它给出错误:找不到“登录”的反向。 “登录”不是有效的 View 函数或模式名称。 网址.py urlpatterns = [ path('admin/', admin.site.urls),
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 2年前关闭。 Improve t
我需要一个自定义的 Facebook 登录按钮。 fb:login-button 的 medium、large 等解决方案不是我需要的。我知道 FB TOS。我的按钮将非常相似。 如何将我的按钮转换为
Spring 版: 2.5.6 SEC01 Spring 安全版本: 3.0.0 RC1 我正在尝试将 Spring Security 与 Spring MVC 应用程序集成。安全部分主要基于 Spr
我是一名优秀的程序员,十分优秀!