utterance / utterances

:crystal_ball: A lightweight comments widget built on GitHub issues
https://utteranc.es
MIT License
8.68k stars 566 forks source link

Failed to load resource: the server responded with a status of 401 () #397

Closed huydhoang closed 3 years ago

huydhoang commented 3 years ago

I inserted utterances in my blog and it is working. But I got this 401 error in Chrome console. POST https://api.utteranc.es/token 401

These are the lines where I got error, specifically this function r.apply(this, arguments); Failed to load resource: the server responded with a status of 401 ()

Does anybody know why? Does this affect commenting functionality in any way?

        "function" == typeof fetch && (fetch = e(fetch, (r = fetch,
        function(t, e) {
            var n = s(e)
              , o = r.apply(this, arguments);
            if (n) {
                function u(t) {
                    c({
                        requestID: n,
                        statusCode: t && t.status
                    })
                }
                o.then(u).catch(u)
            }
            return o
        }
        )));
rscharfer commented 3 years ago

Is this only in incognito? I have that issue as well, and I noticed that it seems to be only an incognito issue. I am not sure if it is a known problem.

rscharfer commented 3 years ago

Actually, if you delete the cookies in normal mode, you will see the issue as well.

brettinternet commented 3 years ago

This appears to occur when the visiting user is not logged in. When I simply logged into GitHub through the script's UI, the HTTP error goes away.

jdanyow commented 3 years ago

This is an expected status/response. The client does a POST to /token to retrieve the user's credentials/signed-in status. If the user is not signed in the service responds with a 401. Maybe I should make this a 204 no content to avoid confusion.

zsdycs commented 3 years ago

401 Unauthorized: The user did not provide authentication credentials, or was not authenticated.

Reference: https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status/401

There is no problem with the response status 401 and it is impossible to be more correct. Sometimes wrong means right. If verification is performed without verification information, verification will naturally fail.

huydhoang commented 3 years ago

Thanks for the answers, guys! I think this can be closed.