Hi.
I have a WiFi network at work that use username and password authentication to allow login to WiFi like airports (Cisco?). The problem is it requires to login every day. And you can guess the password is not 123.
I wonder if it is possible to write an app that do the login. The login page opens in a webviewer or browser so my best idea is to fill the username and password fields somehow. First it is only a brainstorming because I do not even now if it is possible, but I gues it is. Though I am not a network expert neither expert in programming server-client like environments.
Every idea and opinion appriciated.
I will try it. Thank you.
(added to FAQ)
No success yet.
Either because it is a redirected page, (but the webviewer opens it) or because the elements does not have Id, or something else. I will try the redirected page tomorrow. To mess with the second case I have to dig myself in to the javascript and CSS a little. If anyone has any idea that I would appreciate greatly.
An other question.
I would like to use your WiFi manager extension. Only for connect.
I have android 14, API 37.
Can I use the free ver.14 or I have to buy the new version for this API level.
I tried to simply connect it but did not work. I do not know if I need any permission but the app did not give any error message.
Edit: I probably need Location Permission which is not in the free version. Can I Ask for it directly from the android?
Edit: I asked for permission but it did not help. Still does not try to connect.
Google changed a lot in this area as always to offer better security...
From the documentation at App Inventor Extensions: WiFi | Pura Vida Apps
Latest free version of the WiFi extension (without Network Request API and Network Suggestion API methods)
I still provide the latest free version 15 of the extension here without support. There might be permission issues for some methods. Also the Connect method will not work anymore for newer devices. It is recommended to use the paid version instead.
Please read in the documentation about the 2 different connect methods
- Network Request API and
- Network Suggestion API
Taifun
I think I try the long route first, because I do not now if it will work with the paid version or not. Have to figure out everything else first.
My test project is available to test here https://play.google.com/apps/testing/appinventor.ai_taifunbaer.wifi
Taifun
Ok. The test app says it is connected, but for now, the injection code does not work either. So when that will work i will take a look on the paid version. Thank you.
Back to here after some testing.
Well, the auto-populate still does not work, but
If I connect through an app it does not share the username and password with the android system. If I close the app I do not have connection anymore. Either have to keep the app running, or I have to connect through android where I have to put the username and password again. Is there a mode to forward the Wifi authentication to the OS, or something else that I can do?
If you connect to an IOT device through a browser and fill the Wifi details in to the captive portal it is redirect your phone back to that Wifi after the process is complete. How does that work. Or is that only close the connection and the phone just auto reconnect to the asaved network?
New tests shows, when the phone goes to sleep the connection closes. Have to clse the app start again.
I correct it. Does not share the connection. I wonder if it shared at first time at all.
Ok.
I used the wrong method. Better results with the suggestion method. New tests.
I can not make the injection work. Is there a way to obtain the source of the page in the webviewer?
Without knowing its source you can't inject code
Use the browser on your computer to examine the webpage
See the answer from Gemini
Taifun
Examining a webpage's source code, which consists of HTML, CSS, and JavaScript, is a fundamental skill for anyone interested in web development, design, or SEO. This allows you to see how a page is structured and styled. You can do this with your browser's built-in tools.
Viewing the Page Source
This method shows you the raw HTML code that the browser receives from the server. It's a static view of the page's structure and content.
- Keyboard Shortcut:
- Windows/Linux: Press Ctrl + U.
- Mac: Press Cmd + Option + U.
- Right-Click Menu: Right-click anywhere on the page and select "View Page Source" or "View Source."
This will open the code in a new tab or window, where you can see the tags, scripts, and links that make up the page.
Inspecting Elements
For a more dynamic and interactive approach, you can use the browser's developer tools. This allows you to examine and even temporarily edit the HTML and CSS of specific elements on the page.
- Keyboard Shortcut:
- Windows/Linux: Press F12 or Ctrl + Shift + I.
- Mac: Press Cmd + Option + I.
- Right-Click Menu: Right-click on a specific element you want to examine and select "Inspect."
This opens the developer tools panel, which usually appears on the side or bottom of your browser window. The "Elements" tab will show you the live HTML and CSS of the page. You can hover over elements to highlight them on the page, and click to see their associated CSS rules
Without knowing its source you can't inject code
Yes, I just tried to guess it, because what would you named a Username and Password field. Obviously something similar. Because of handiness. Everyone do it that way.
I tried several way.
Anyway, in the mean time I have found a way to see the source code in chrome. . so I started working on the injection.
Thank you.
Autofill works, but click not yet. Almost there.
Update: Click was just a mistype. Everything works perfectly now.
Great to hear! It would be nice, if you could share a screenshot of some relevant blocks of your solution!
Taifun
No problem.
Technically just needed your extension for the WiFi connection, and of course the source code of the captive portal that something like this:
After that it was easy with your help about the javascript injection example and the html help webpage.
When first start you have to insert the credentials, and touch login. It saves and login too. After that it is holding the credentials in tinyDB so autofill it in every start of the app, which I had to do every time manually when left the WiFi. No Just every day, and thanks to the suggestion API it reconnects until next day if Ioose the connection for some reason.
Many thanks four your help!
There is a little problem that I do not know the cause of yet. When I log in with the app and close it it disconnects. I have to turn off the WiFi on my phone an turn back on and it reconnect automatically and stays. Trying to figure out why do I have to turn the WiFi off and on.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.