Basic authentication

71 views
Skip to first unread message

Harshit Aggarwal

unread,
Jun 27, 2019, 9:44:52 AM6/27/19
to net...@chromium.org
Hello sir/madam,
I wanted to know if I can make a basic authentication HTTP request in a Chrome extension.
$http({
method: "POST",
url: "https://starclinch.com/wp-json/acf/v3/posts/,
headers: {
'Authorization':'Basic aGFyc2hpdHN0YXI6bmVvbjA0JEhBUzE=',
'content-type': 'application/json'
}
})
I wrote this code which works perfectly in a webpage but it gives an Unauthorized status code of 401.
Please help.
Thank you

Eric Roman

unread,
Jun 27, 2019, 3:56:42 PM6/27/19
to Harshit Aggarwal, net-dev
CORS.

I am guessing you are doing a fetch() from a Chrome extension background page, in which case the Origin being sent to starclinch will look something like chrome-extension://XXXXXXXX.

From some quick testing, starclinch is fine with Origins of http://* and https://* origins, however doesn't accept chrome-extension://* origins.

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAHv8%3D%3Duf8HXQSJy_MgTinDNP2cCjzwn6HWCR_zK_b9ihU8ZZxQ%40mail.gmail.com.

aggarw...@gmail.com

unread,
Jun 28, 2019, 9:40:50 AM6/28/19
to net-dev, aggarw...@gmail.com
"permissions":
[
"storage",
"tabs",
"declarativeContent",
"unlimitedStorage",
"https://starclinch.com/",
"http://artist.starclinch.com/"
]
Thank you very much for responding. My manifest,json already has starclinch. So is it due to a bug? https://snag.gy/NQ8e70.jpg is the screenshot of the console log for your reference.

I also tried adding 'webRequest' to the 'permissions' array and got this error message: The 'webRequest' API cannot be used with event pages

Eric Roman

unread,
Jun 28, 2019, 2:11:22 PM6/28/19
to Harshit Aggarwal, net-dev
For Extensions questions I will refer you to chromium-...@chromium.org

--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.

Harshit Aggarwal

unread,
Jun 28, 2019, 3:39:18 PM6/28/19
to PhistucK, Eric Roman, net-dev
"permissions": 
[
"storage",
"tabs",
"declarativeContent",
"unlimitedStorage",
"https://starclinch.com/",
"http://artist.starclinch.com/"
]
Thank you very much for responding. My manifest,json already has starclinch. So is it due to a bug? I've attached the screenshot of the console log for your reference.


I also tried adding 'webRequest' to the 'permissions' array and got this error message:  The 'webRequest' API cannot be used with event pages

On Fri, Jun 28, 2019 at 4:00 AM PhistucK <phis...@gmail.com> wrote:
Normally, if you add a host permission to your manifest.json for that host, I think it should not send an Origin header.
However, due to a bug, it may still send it (there may be ways using chrome.webRequest to remove it, though), but try it.

PhistucK


ss.png

PhistucK

unread,
Jun 28, 2019, 3:39:18 PM6/28/19
to Eric Roman, Harshit Aggarwal, net-dev
Normally, if you add a host permission to your manifest.json for that host, I think it should not send an Origin header.
However, due to a bug, it may still send it (there may be ways using chrome.webRequest to remove it, though), but try it.

PhistucK


On Thu, Jun 27, 2019 at 10:56 PM Eric Roman <ero...@chromium.org> wrote:

aggarw...@gmail.com

unread,
Jul 1, 2019, 10:49:04 AM7/1/19
to net-dev, ero...@chromium.org, aggarw...@gmail.com
I already have it in my manifest.json. So is it due to that bug?
Reply all
Reply to author
Forward
0 new messages