标签: unauthorized

Chrome中的401(未经授权),但不在IE中

我最近从使用jQuery转向使用Redux的isomorphic-fetch.在IE中运行时,它设法获取正常.但是我在Chrome中运行时会得到以下内容.

Failed to load resource: the server responded with a status of 401 (Unauthorized)
Run Code Online (Sandbox Code Playgroud)

值得注意的是,web api确实启用了Windows身份验证.

这是执行fetch的代码:

export const fetchSearchResults = (name) => {
  return (dispatch) => {
    dispatch(requestSearchResults(name))
    return fetch(API URI HERE)
      .then(response => response.json())
      .then(json => {
        console.log('Fetch: ' + json.message.features.length)
        dispatch(receiveSearchResults(json))
      })
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome unauthorized fetch redux

8
推荐指数
1
解决办法
9240
查看次数

Overriden HandleUnauthorizedAsync不被称为.NET Core

我已经实现了自己的自定义身份验证中间件和处理程序,并在应用启动时配置了它们.这一切都很好.

在我的自定义auth处理程序中,我已经覆盖了HandleAuthenticateAsync()以执行我自己的自定义身份验证,我还重写了HandleUnauthorizedAsync()以便将用户重定向到登录页面,但是这不会被调用.

浏览器在响应中收到401(未授权).我期待调用我的HandleUnauthorizedAsync().

我在这里没有正确理解管道吗?

谢谢

.net unauthorized custom-authentication asp.net-core

8
推荐指数
3
解决办法
1354
查看次数

FCM 推送 - 请求的身份验证凭据无效。需要 OAuth 2 访问令牌、登录 cookie 或其他有效的身份验证凭据

我正在尝试使用 cURL 命令将 fcm 消息发送到特定主题,但它显示错误,例如

{ "error": { "code": 401, "message": "请求的身份验证凭据无效。需要 OAuth 2 访问令牌、登录 cookie 或其他有效的身份验证凭据。请参阅https://developers.google.com/identity/登录/web/devconsole-project。” , “状态”: “未经身份验证” } }

在此输入图像描述

我使用了 firebase 控制台中的服务器密钥

在此输入图像描述

我遵循了FCM 文档

如何解决此 401 错误。

curl unauthorized push-notification firebase firebase-cloud-messaging

8
推荐指数
1
解决办法
2215
查看次数

为什么我的.Net应用程序与Verisign联系?

我写了一个与网络通信无关的.Net应用程序.在使用NIC的整个应用程序中没有一行代码,但我的防火墙已经发现它在应用程序启动时因某些原因尝试联系Verisign.这不会经常发生; 事实上,它只发生过两次.

最后一次,我告诉我的防火墙允许访问网络之前,我能够启动Wireshark.我没有真正的数据传输.它只捕获了9个TCP数据包:一些SYN数据包,一些SYN/ACK和一些RST数据包(RST数据包被破坏).我怀疑我的第三方dll之一,但我不明白为什么数学库或图像处理库会尝试与Verisign建立连接,然后对该连接不做任何处理.

我的客户在安全严密的组织中; 我想要的最后一件事是打电话询问为什么我的应用程序连接到Internet.

有谁知道为什么会这样?有没有办法防止它发生?

Wireshark生成的.pcap文件在这里.

.net networking startup unauthorized verisign

7
推荐指数
1
解决办法
852
查看次数

在致电Google GCM时未经授权

我尝试使用Google GCM发送推送通知.但得到一个WebException,说远程服务器返回401 unautorized.我无法理解为什么它不起作用.

有谁知道它为什么不起作用?

这是我的代码:

            ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateServerCertificate);

           HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://android.googleapis.com/gcm/send");


            Request.Method = "POST";
            Request.KeepAlive = false;

            string postData = "{ 'registration_ids': [ '"+registrationId+"' ], 'data': {'message': '"+message+"'}}";

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            Request.ContentType = "application/json";
            //Request.ContentLength = byteArray.Length;


            //Request.Headers.Add(HttpRequestHeader.Authorization, "GoogleLogin auth=" + AuthString);
            Request.Headers.Add(HttpRequestHeader.Authorization, "Authorization: key=AIzaSyCEygavdzrNM3pWNPtvaJXpvW66CKnjH_Y");
            //-- Delegate Modeling to Validate Server Certificate --//


            //-- Create Stream to Write Byte Array --// 
            Stream dataStream = Request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            //-- Post a Message --//
            WebResponse Response = …
Run Code Online (Sandbox Code Playgroud)

c# android httpwebrequest unauthorized google-cloud-messaging

7
推荐指数
2
解决办法
2万
查看次数

仅允许在ASP.Net MVC中使用匿名的属性

我知道用户必须进行授权时才有一个属性.你也可以放在[AllowAnonymous]它上面.另见下面的代码:

[Authorize] // only when the user is authorize
public class AccountController : Controller
{
    [HttpGet]
    [AllowAnonymous] // also when the user in not authorize.
    public ActionResult Login(string returnUrl = "")
    { /* Some code */ }

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
    { /* Some code */ }
}
Run Code Online (Sandbox Code Playgroud)

但是还有一个仅允许匿名的属性.例如:登录页面仅在用户未授权时显示

authentication asp.net-mvc authorization unauthorized

7
推荐指数
1
解决办法
3214
查看次数

防止未经授权的http请求重定向到/错误设置会话cookie - spring boot - spring security

语境

我的申请遇到了一些问题。我们使用 Spring Boot 2.4.10 和 Spring Security 5.4.8。我们使用 cookie 与应用程序交互。

我们有一个存储在src/main/resources其中的前端应用程序,其中包括连接到/api/v1/notification.

我的配置

application.properties文件:

# cookie-related settings
server.servlet.session.cookie.name=mySessionCookie
server.servlet.session.cookie.path=/
server.servlet.session.cookie.http-only=true
server.servlet.session.cookie.secure=true
Run Code Online (Sandbox Code Playgroud)
# cookie-related settings
server.servlet.session.cookie.name=mySessionCookie
server.servlet.session.cookie.path=/
server.servlet.session.cookie.http-only=true
server.servlet.session.cookie.secure=true
Run Code Online (Sandbox Code Playgroud)

问题

当没有用户登录时,前端会尝试定期访问 websocket 端点以打开连接。

第一个api/v1/notification结束重定向到/error端点,该端点返回HttpServletResponse带有“Set-Cookie”标头(我认为这可能是在第一个请求中设置的匿名 cookie?)和401状态。我无法改变这种行为。

以下请求api/v1/notification在标头中使用此 cookie(当用户未登录时)。这些请求也会重定向到/error端点,该端点每次都会返回HttpServletResponse401状态,但这里不包含“Set-Cookie”标头。

用户使用授权标头登录后,响应将设置正确的 cookie 并在以下请求中使用。

问题是,有时设置的 cookie 会突然再次更改为无效 cookie,并且使用此新的无效 cookie 完成的后续请求会重定向到登录页面。

检查代码后,似乎发生了一个旧api/v1/notification请求(在登录请求之前),其中包含无效的 cookie(匿名请求,在登录之前存在)。

该请求被重定向到/error端点:这里再次HttpServletResponse出现401状态,并且包含一个 Set-Cookie …

java spring-security unauthorized session-cookies spring-boot

7
推荐指数
1
解决办法
1277
查看次数

PhoneGap和Google Maps API V3"已停用?"

所以,我正在构建一个简单的PhoneGap应用程序来加载Google Maps API V3视图.我已经广泛搜索了答案,但我还没有找到答案.尝试加载API时出现以下错误:"Google已禁用此应用程序使用Maps API.提供的密钥不是有效的Google API密钥,或者未授权使用Google Maps Javascript API V3现场."

我尝试了一切.在Cordova中,我将所有域列入白名单(" "),并在Google Play开发者控制台(" ")中使用相同的域名.我甚至尝试过将"file://"列入白名单,但没有这样的运气.

让我疯狂的是,当我使用我的代码超出PhoneGap的范围时,它运行正常.任何人都能解释一下吗?谢谢!

android google-maps unauthorized google-maps-api-3 cordova

6
推荐指数
1
解决办法
1302
查看次数

使用Parse.com javascript并继续获取401未经授权

我正在进行初始化,因为我应该使用正确的键等.即使在稍后使用Parse.Cloud.run的函数中这样做,我仍然会获得401未授权.

有没有办法看看初始化是否正常工作?它会回复任何形式的回应吗?错误?如果是这样,我该如何看待所述回复?初始化目前只是:

Parse.initialize("appid", "javascript key"); (with the correct keys of course).
Run Code Online (Sandbox Code Playgroud)

然后我称之为云功能:

Parse.Cloud.run('testfunction', aUserObj, {
                success: function(result) {
                    supersonic.ui.dialog.alert(result);
                },
                error: function(error) {
                    supersonic.ui.dialog.alert(error);
                }
            });
Run Code Online (Sandbox Code Playgroud)

并且错误是未经授权的401(我也在javascript控制台中看到POST api.parse.com ..... 401未经授权).

顺便说一句 - 使用curl和rest api密钥我可以使它工作没有问题,所以它不是一个真正的权限问题,我可以告诉.

谢谢.

javascript unauthorized parse-platform

6
推荐指数
1
解决办法
1654
查看次数

使用带有 Asp.net Core API 的身份服务器 4 获取 401 Unauthorized with valid access token

我在我的 Asp.net core API 应用程序中使用身份服务器 4,我在本地服务器 https://localhost:[port]/connect/token上获得成功的令牌 ,它提供访问令牌,当我使用不记名令牌访问时授权方法然后它工作正常
,但在服务器 https://example.com/connect/token它也给出成功的令牌,但是当我使用此令牌访问授权方法时,它给出401 未经授权的错误

  "Authority": "https://example.com",
  "Audience": "https://example.com/resources",
  "RequireHttpsMetadata": "true"


 services.AddIdentityServer(options =>
        {
            options.Events.RaiseErrorEvents = true;
            options.Events.RaiseInformationEvents = true;
            options.Events.RaiseFailureEvents = true;
            options.Events.RaiseSuccessEvents = true;
        })
            .AddDeveloperSigningCredential()
            .AddInMemoryPersistedGrants()
            .AddInMemoryIdentityResources(GetIdentityResources())
            .AddInMemoryApiResources(GetApiResources())
            .AddInMemoryClients(GetClients())
            .AddAspNetIdentity<User>();

        services.AddAuthentication(options =>
        {
            options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
            options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
        })
        .AddJwtBearer(options =>
          {
              options.Authority = configuration["AppSettings:Authority"];
              options.Audience = configuration["AppSettings:Audience"];
              options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AppSettings:RequireHttpsMetadata"]);
          });
        services.AddTransient<IProfileService, IdentityClaimsProfileService>();



    public static IEnumerable<IdentityResource> GetIdentityResources()
    {
        return new List<IdentityResource>
        { …
Run Code Online (Sandbox Code Playgroud)

unauthorized authorize-attribute bearer-token identityserver4 asp.net-core-webapi

6
推荐指数
1
解决办法
9022
查看次数