【 Case description 】

Recently, after I packaged my Web H5 application into QuickApp, when I registered and logged in with Google account, I encountered the 403 error as shown in the figure below.

[Problem Analysis]

As you can see from the Error page above, Google gives us the reason: Error: disallowed_useragent. That said, Google has limited the browser UA that can load H5 apps, and it recommends Chrome. Obviously the answer has something to do with UA.

[Solution]

  1. Define the variable model, which represents the user’s mobile phone model, and add the model variable to the data object. The code is as follows:

  1. Assign a value to the model: Get the phone model number in the onInit() method of the page’s lifecycle, as follows:

1

2

3

4

onInit: function () {

const device = require(`”@system.device”`)

const res = device.getInfoSync();

this`.model=res.model; `

  1. Set the Web component property UserAgent value to Mozilla/5.0 (Linux; Android 9; {{model}}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.116 Mobile Safari/537.36)

Note: The value of UserAgent uses the variable model. The function of using the variable model is to get the real mobile phone model, so as to avoid some H5 web pages that get the wrong mobile phone model when verifying the UserAgent, which may cause trouble to the user.

4. Set the MINPLATFORMVERSION value in the MANIFEST.JSON file to 1068.

5. Please ensure that the version of Huawei Quick App Loader is 2.2.0.304 or above. The way to view the loader version is shown in the figure on the right:

Note: 1, 2, 3, 4After the steps are completed, if you still have problems logging in, please visit the webon

Add the following code:

multiwindow=”true”

  • H5 application packaging into fast application is a very important solution overseas. On the mobile phone without GMS service, you can still use Google’s services, such as the Google account in this case.
  • The solution of this case is also applicable to H5 fast application other account login problems.

The original link: https://developer.huawei.com/…

Author: Mayism