🟨 WebViewExtra - Upload/Download Files with webviewer

<form action="upload.php" method="POST" enctype="multipart/form-data">
    <label for="fileToUpload">Select files to upload:</label>
    <input type="file" name="fileToUpload[]" id="fileToUpload" multiple accept="image/*" capture="camera" />
    <input type="submit" value="Upload" />
</form>

You can pick the files using ActivityStarter android.intent.action.PICK and then upload them using a Clock.

The webviewextra extension is set to only allow one file. Hopefully @vknow360 can find a solution for you with CustomWebView.

As you may have seen, there are many other ways to upload multiple files in AI2, without using a webview.

p327C_subir_archivos.aia (3.7 KB)

<?php
// Juan A. Villalpando
// kio4.com
$data = file_get_contents('php://input');
file_put_contents($_GET['archivo'],$data);

$nombre_archivo = $_GET['archivo'];

$fp = fopen($nombre_archivo, 'r+b');
$data = fread($fp, filesize($nombre_archivo));
fclose($fp);
echo "Archivo guardado: ".$nombre_archivo;
?>

I have been using WebViewExtra1.1 to invoke google authorization and it worked well on Android 13, Android 9 however, After AI SDK update for SDK33 support it stopped working and ends with the following error message.

The error I get is Error 403: disallowed_useragent.

Could you please let me know if I need to wait for an updated WebViewExtra1.1 ?
or if there is a tweak that I need to follow, kindly let me know.

Thank you

I have no android 9 device to test on, but let's assume your issue is android less than 10. I can test on android 5 & 7.

Can you describe how you are using Google OAuth to generate this error?

Is this with a compiled app or in companion ? If compiled, do you have a version compiled before the n194 release that works with Android 9? Do you also have a saved aia project created before n194 ?

I am using standard google api,
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline
with following scope to get readonly access to emails.
https://www.googleapis.com/auth/gmail.readonly

Just to let you know, the web app code works when directly tested on desktop chrome and worked fine in android mobile as well till the recent upgrade to Android 13.

I tested on Android 13 and Android 9 only and it worked perfectly prior to AI MIT SDK upgrade. Please refer the error screen shot

Thanks for your help

I have just tested a simple web app with Android 7 in companion and it works OK through the OAuth process. Also tested when compiled, and the OAuth works OK there too.

You can try it on your Android 9 device, I will message you the aia project.

Sure. I'll test and let you know the outcome.

Thanks!

Now tested and working on Android 9.

Seems it may be a specific device issue (is your Android 9 device a Samsung?), or some other bug....

I use ASUS Zenfone M2 to test the app on Android 8.x.
I also tested the wvetest app on Android 13 - Samsung mobile, which also gave similar message.
Please refer the screenshot for android13
Thanks!

It is possible that these devices are using a different useragent

Sharing the useragent details, Please take a look:

Asus Android 8.1 has the following useragent
Mozilla_5.0_(Linux;_Android_8.1.0;_ASUS_X01BDA_Build_OPM1)AppleWebKit_537.36(KHTML,_like_Gecko)_Version_4.0_Chrome_116.0.0.0_Mobile_Safari_537.36

Samsung Android 13 uses the following useragent
Mozilla_5.0_(Linux;_Android_13;_SM-E236B_Build_TP1A.220624.014)AppleWebKit_537.36(KHTML,_like_Gecko)_Version_4.0_Chrome_116.0.0.0_Mobile_Safari_537.36

Yep, thank you for providing that, this is the issue.

I am just in the middle of working up a possible fix

Just wanted to reshare the details, my debug had replaced spaces with underscore () to check if there are any special character, hence my earlier useragent details had the filler as "".
Please refer this one without underscore

Asus Android 8.1 has the following useragent

Mozilla/5.0 (Linux; Android 8.1.0; ASUS X01BDA Build OPM1) AppleWebKit/537.36 (KHTML, like Gecko) Version 4.0 Chrome/116.0.0.0 Mobile Safari 537.36

Samsung Android 13 uses the following useragent
Mozilla/5.0 (Linux; Android 13; SM-E236B Build TP1A.220624.014) AppleWebKit/537.36 (KHTML, like Gecko) Version 4.0 Chrome/116.0.0.0 Mobile Safari 537.36

Google now seem to be blocking on my Android 13 device (Google Pixel 4a) !!!

Could it be possible they're also looking at "Mobile" word in the useragent (Mobile Safari 537.36) to disallow ?

Try this

wveTestV2.aia (18.1 KB)

Tried the new wveTestV2 app on Android 8.1 ASUS, it gave a different message about the browser. Please see attached screen shot.
*** UPDATE ***
I replaced the default value (Edge browser) in setUserAgentString in wveTestV2 to the below string and it works fine - Authorisation was successful.

Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Safari/537.36

Also, quick info, when I tested my AUTH code using the following user agent it works.
"Galaxy TAB S4" ===>
Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Safari/537.36'

Thanks!

1 Like

Looks like I will have to drop the old and simple method of find and remove ; wv and simply offer the set userAgentString block, with some suggestions....

I am finding if I tweak the default userAgent string, removing Version/4.0 and : wv and Mobile, then it works on Android 13

1 Like