Android Question How to Authenticate only Android user to visit web site

cenyu

Active Member
Licensed User
Longtime User
Hello, i have a task to create web site with MSSQL database and ASP.NET C# MVC but this site MUST be accessable only from users with my B4A app and not accessable from web browsers and other phones with different IMEI...
I can use HttpJob like this code to receive data or entire web page and send username password and Phone IMEI
B4X:
    Public appUrl1 As String = appServer & "/page1/__USERNAME__/__PASSWORD__/_PHONEIMEI__"

    Dim job3 As HttpJob
    job3.Initialize("JobLogin", Me)
    job3.Download(appUrl1)
OR

B4X:
Dim Web as WebView
Web.LoadURL(appUrl1 )

But my biggest concern is: IF USER WRITE THIS URL DIRECTLY TO BROWSER IT WILL ACCESS SITE.
User MUST load site ONLY from WebView into my B4A app
How to protect site? Any answer will be useful for me!
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
WebviewExtras2 is not a different version of webview, it just adds "extra" features to the existing webview.

It is highly recommended that you post details or the code of the solution so other members can learn from the issue in this thread.

So, what function of webview extras did you use specifically that fixed this issue?
 
Upvote 0

annitb

Member
Licensed User
Longtime User
there is a single tcp packet knock knock utility on entware(ng)...you send a packet from the app and only then is the perfectly normal web server port available for a perfectly standard http request...just saying...since a browser cannot send that tcp packet, only your android app users will be able to access that website...say for html apps or the like..
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK, I see you posted your solution at this location:


So, there was an SSL problem, and you are using Webviewextras2 to ignore the SSL error.

I wanted to post this solution so other forum members can learn.
 
Upvote 0

cenyu

Active Member
Licensed User
Longtime User
OK, I see you posted your solution at this location:


So, there was an SSL problem, and you are using Webviewextras2 to ignore the SSL error.

I wanted to post this solution so other forum members can learn.

How can i help you?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
You didn't post the code that solved the problem you were having in this thread.

So, I just wanted to update this thread with the same solution you posted in another thread.

This way members reading this thread can see your solution in the other thread.
 
Last edited:
Upvote 0

cenyu

Active Member
Licensed User
Longtime User
You have to download lib from http://b4a.martinpearman.co.uk/webviewextras/

Then use this code to load https web page:
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private WebView1 As WebView
    Private we As WebViewExtras


End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")

    we.Initialize(WebView1)
    Dim client As DefaultWebViewClient
    client.Initialize("client")
    we.SetWebViewClient(client)
    WebView1.LoadUrl("https://192.168.0.200/")


End Sub

Sub client_ReceivedSslError(SslErrorHandler1 As SslErrorHandler, SslError1 As SslError)
    Log(SslError1)
    SslErrorHandler1.Proceed
End Sub

The Sub client_ReceivedSslError is very important! Without this sub nothings work!
 
Upvote 0
Top