Aborting loading of script if HTTP Basic Auth fails - html

I'm loading a cross-origin script that requires a username/password using HTTP Basic Access Authentication.
I'm not concerned with the security of the username/password. My code:
<script src="http://user:password#example.com/script.js"></script>
This works fine in most cases. However, if the credentials are incorrect, an authentication dialog pops up.
I would like to abort the loading of the script if the credentials are wrong instead of presenting the authentication dialog to the user. Ideally a JavaScript function would be triggered as well to alert that something has gone wrong.
Is this possible, and how would it be done?

I think this would fall on the server-side configuration.
Instead of sending a HTTP 401 Not Authorized with WWW-Authenticate header, the server should respond with a different status code, perhaps 403 Forbidden
The problem is that when a 401 is sent to the browser, the browser interprets that as a login requirement, prompting the user. If it receives another error status (i.e. 403) it will simply error out (which can be caught by a JavaScript function)

Related

Problem with accessing the api in a web page hosted in the IIS

I am making a forge web application, I have this page on an IIS server and it does not work for me, it does not display the model and it generates the following error in the front:
onDocumentLoadFailure() - errorCode:7
ForgeViewer.js
when I run my application locally and it generates a port if it works correctly.
Could you help me since I think the error is that you can access the api or something from a port that forge uses for the IIS
Thank you so much
Error code 7 stands for:
An unhandled response code was returned when accessing a network resource (HTTP 'everything else')
This error is issued by the viewer when its requests fail with response code other than 401, 403, 404, or 5XX.
I'd suggest that you check the Network tab of your browser's dev tools. For example, here's how to do that in Google Chrome. The failing request (typically highlighted in red) can typically provide more information about why it failed.

How to find out why my server has been blocked

I have an application token. According to documentation
If you are throttled for any reason, you will receive a status code
429 response.
I have received no errors that I am being throttled. Sending requests from other servers are accepted just not the one that has been working fine up until today. What needs to be done to unblock my server and/or prevent it from reoccurring?

Is there a way to get https requests to work when calling from a localhost for testing

I'm getting the errors when testing my application locally since I switched to https:
Warning: Domain www.example.com does not specify a meta-policy.
Applying default meta-policy 'master-only'. This configuration is
deprecated. See http://www.adobe.com/go/strict_policy_files to fix
this problem.
Error: Request for resource at
https://www.example.com/?json=user/get_logged_in_user by requestor
from http://localhost:8888/Test-debug/Test.swf is denied due to lack
of policy file permissions.
I tried changing my localhost to https but got the following error:
Secure Connection Failed
An error occurred during a connection to localhost:8888. SSL received
a record that exceeded the maximum permissible length. Error code:
SSL_ERROR_RX_RECORD_TOO_LONG
The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.
From what I've read I can upload and add a policy file and changing secure to true but I don't want to allow calls from anywhere. Once the swf is on my server everything works fine.
Is there a way to get this to work locally for testing? Is there something that I can enable while testing like:
Security.allowDomain("localhost");
Or do I have to upload a cross domain policy and then delete that policy when I'm done testing?
Since my local site is running locally in the browser shouldn't it be able to make a connection to a https connection?
Using of https (btw it does not configured properly according to message you posted (did you use FireFox to test?)) will not help. The problem is that www.example.com does not have crossdomain.xml policy file, so flash player does not allow to access that domain from your localhots which is also a domain.
If you have an access to www.example.com add policy file here with wildcard access, if not - test via http is possible only with mocking response with some http proxy.
I changed to testing using file:// (no server) and it works making https calls.

Unable to use fetchURL() in Google apps scripts

I am trying to call the below URL from Google apps script. In my browser it works fine, but when run from Apps script I get the error 'Access denied'.
var response=UrlFetchApp.fetch(url);//Fails with Access denied exception
URL :
Gets stock data in JSON format
'Request failed for http://www.nseindia.com/live_market/dynaContent/live_watch/get_quote/ajaxGetQuoteJSON.jsp?symbol=AXISBANK&series=EQ returned code 403. Truncated server response: Access Denied Access Denied You don't have permission to access "http://www.ns... (use muteHttpExceptions option to examine full response)'
Do i need to do anything extra?
Status 403 indicates that everything went as planned, but the recipient denied the request. Without clarification from the host site, it's hard to say why it's rejecting the request, but it could be anything from the request being denied due to an issue with your code, or they may have a service in place that prevents these kinds of requests from unauthorized IPs.
They may even have blacklisted Google apps script specifically, due to the nature of the site you're connecting too, and the potential for abuse.

Chrome error after hitting back to safety on the security page

So after i hit back when seeing the message on chrome saying that my connection isnt secure on a HTTPS
now i can not access this page on my network and can only access it on my vps... is there any way I can fix this i searched all over the web and im so blown cause now i can't access my own webpage..
PS: I have tried accessing the page on another computer on the same network and i get the same error message of ERR_CONNECTION_TIMED_OUT when ever i try to go to the page, and yes i have tryed connecting on another router and the page loads fine and is a live copy of the page. please help me
Your connection is not private
Attackers might be trying to steal your information from xxxxx.com (for example, passwords, messages, or credit cards).
Back to safety Hide advanced
This server could not prove that it is (website).com; its security certificate is from server1.(website).com. This may be caused by a misconfiguration or an attacker intercepting your connection.
Proceed to (website).com (unsafe)
NET::ERR_CERT_COMMON_NAME_INVALID