URLConnection with login

I am trying to use the URLConnection to retrieve data from a URL but it needs a login. I can view the data in a web browser because the web browser gives me the chance to enter the username and password via a pop up box (like some router/modems). The URL is https://api.cricviz.com/site/v2/match
I am using: URLConnection1.Send(“GET”, “https://api.cricviz.com/site/v2/match/”) but in the ContentRecieved event I just get a 401 error, the same as if you click on the cancel button on the login box in a web browser.
Is there any way to make it work?
Thanks!

Are they using this cricket API? If yes, then you find the documentation here:
https://www.cricketapi.com/docs/

and for authentication here:
https://www.cricketapi.com/docs/Core-API/Auth-API/

No, it is their own API. The question is not realy in relation to this specific API but any that needs authentication like this. In other coding software, I can set a username and password for authentication, but I can not see how to do this with Xojo.

I did not find the documentation of their api, so I can only give a general information:

Either you add the identification as parameters to the url or you set the identification as variables in the request header.

Often it is done this way: first one requests a unique token at the beginning by setting ID and Password in the request header and then calling the Authorization route of the api. then one uses the token with any further call to the api.

See the discussion here:
https://forum.xojo.com/52638-sms-rest-api-python-xojo-cloud/p1#p426363

or maybe better here;
https://forum.xojo.com/46465-oauth-and-api/p1#p410425

https://documentation.xojo.com/api/networking/urlconnection.html#urlconnection-authenticationrequested

Maybe?

Thanks, @Jason King

I didn’t think about it being a reactive event handler. I was trying to be proactive and was expecting to have to send the login in advance along with the initial connection. So I was looking for properties or methods.