Recently, a developer needed to access HUAWEI AppGallery Connect API and create a product through the PMS API (server API). However, when Postman was used for basic service interconnection tests, the error message "403 client token authorization fail" was displayed.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
They checked the error code description and found that the error was caused by an authentication failure.
1. To solve the problem, they first confirmed that the client ID used for applying for the token had sufficient permission.
2. The official document suggested that the project associated with the API client be selected as N/A. They created an API client and associated it with a project. An app ID in this project was 100xxx591. However, the app ID in the Postman service request was 101xxx531, which might have caused the authentication failure.
3. To verify the assumption, they created an API client and selected N/A (indicating that all projects are supported) and used the client to request a token. The process then went well.
To draw a conclusion, If Huawei's 403 authentication failure occurs, you can verify the permission first, and then check the associated projects.
Reference:
For details about the PMS API, please refer to:
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-References/agcapi-addproduct
For more details, you can go to:
Official website
Development Documentation page, to find the documents you need
Reddit to join our developer discussion
GitHub to download demos and sample codes
Stack Overflow to solve any integration problems
Related
Symptom:
When the getRankingIntent API is called, which is related to leaderboards, the following error message is displayed.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Log Information
The following error information is displayed in the Android Studio Logcat logs:
HTML:
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant W/HwGameAssistant-10.6.0.301-RequestHelper: client.assistant.gs.leaderboard.scores reponse fail code:502, msg:Bad Gateway
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant E/HwGameAssistant-10.6.0.301-GameRankingScoreListViewModel: getHttpStatusCode is : 502
Troubleshooting
The test result shows that the game sign-in function is normal. Therefore, the problem is not caused by a network error. After studying relevant documents, we checked the following items:
1. First, we ensured that the package name and app ID belong to the same game.
2. Then, we checked whether leaderboards have been created for the game in HUAWEI AppGallery Connect. It was found that leaderboards have been added for another game. We attempted to resolve the problem. However, testing shows that the problem still persists.
3. Finally, it was found that the account we used for testing is not on the list of test accounts in AppGallery Connect. After adding it to the list and clearing HMS Core (APK) cache on the phone, the problem is solved.
Summary:
If you find that the leaderboard function is abnormal, ensure that:
The app ID and the package name belong to the same game.
Your game has its leaderboard data created in AppGallery Connect.
Your test account has been added in AppGallery Connect.
For more details, check:
Adding a Leaderboard:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-add_leaderboard
Managing Tester Accounts:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-tester_account_mgt
Symptom:
When the getRankingIntent API is called, which is related to leaderboards, the following error message is displayed.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Log Information
The following error information is displayed in the Android Studio Logcat logs:
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant W/HwGameAssistant-10.6.0.301-RequestHelper: client.assistant.gs.leaderboard.scores reponse fail code:502, msg:Bad Gateway
2020-10-22 11:14:17.831 27218-3850/com.huawei.gameassistant E/HwGameAssistant-10.6.0.301-GameRankingScoreListViewModel: getHttpStatusCode is : 502
Troubleshooting
The test result shows that the game sign-in function is normal. Therefore, the problem is not caused by a network error. After studying relevant documents, we checked the following items:
1. First, we ensured that the package name and app ID belong to the same game.
2. Then, we checked whether leaderboards have been created for the game in HUAWEI AppGallery Connect. It was found that leaderboards have been added for another game. We attempted to resolve the problem. However, testing shows that the problem still persists.
3. Finally, it was found that the account we used for testing is not on the list of test accounts in AppGallery Connect. After adding it to the list and clearing HMS Core (APK) cache on the phone, the problem is solved.
Summary:
If you find that the leaderboard function is abnormal, ensure that:
The app ID and the package name belong to the same game.
Your game has its leaderboard data created in AppGallery Connect.
Your test account has been added in AppGallery Connect.
For more details, check:
Adding a Leaderboard:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-add_leaderboard
Managing Tester Accounts:
https://developer.huawei.com/consumer/en/doc/distribution/app/agc-tester_account_mgt
The Content of part1 is here.
Generating and Configuring a Signing Certificate Fingerprint
Use the preceding signature file to generate a signing certificate fingerprint by referring to Huawei documentation, and configure the fingerprint in HUAWEI AppGallery Connect.
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/appgallerykit-preparation#h2-1604304489444
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Packaging and Running the Demo
Step 1: Choose Android from the Platform area, and click Switch Platform.
Step 2: Click Build And Run and select the preceding signature file.
If this message is displayed, you can manually delete useProguard in the launcherTemplate.gradle file.
In this example, the following two lines are deleted.
Package and run the demo again.
Step 3: Check whether the packaged demo is normal.
Once you have packaged and run the demo, the following page is displayed.
Click Init. A message is displayed, indicating that the operation is successful.
Click Login and then login. The HUAWEI ID sign-in page is displayed, indicating that the demo is running successfully.
You can view the method of calling APIs for the demo in the following file in Unity, and call the corresponding APIs.
Note: If the sign-in page is not displayed, and the 6003 result code is returned, the signature fingerprint may be inconsistent. For details about how to fix this problem, check this post: What Can I Do When Result Code 6003 Is Returned?
Part1 of this thread: https://forum.xda-developers.com/t/...rovided-by-unity-part1.4212917/#post-84224243
SymptomI have integrated the trial play function provided by the HMS Core Game Service SDK 5.0.1.302 into my game and completed the following as instructed by the official documentation:
Applying to enable the forcible identity verification function.
Adding code snippet for implementing trial play to my game code.
However, when my game was launched and the identity verification pop-up was displayed, the trial play option was not available, which means that the function did not take effect.
AnalysisIt was the first time I integrated the HMS Core SDK, so I contacted Huawei technical support. I was informed of some of the prerequisites for enabling the trial play function:
1. The integrated Game Service SDK version must be 5.0.1 or later.
2. The forcible identity verification has been enabled.
3. Code relating to the trial play function has been added.
4. The default authorization parameter of the game must be DEFAULT_AUTH_REQUEST_PARAM_GAME.
We have met the first three, but not the last one.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
SolutionFinally, I modified my code by referring to the documentation, and it worked! Hope this post can offer you some help!
Am not sure but check the code for suttle errors
Tennaric said:
Am not sure but check the code for suttle errors
Click to expand...
Click to collapse
this is just a sample code. you can refer to this site to confirm the correct usage. you can even download the sample code in github.
Auth Service provided by AppGallery Connect supports multiple third-party authentication modes such as HUAWEI ID, WeChat, QQ, Facebook and Twitter, covering most popular sign-in methods. Today we take a look at two issues that you might come up against when integrating the Auth service using a third party.
Result code: 203817990 Error message: fail to get third user union idThis error usually occurs when we integrate HUAWEI ID authentication. When we sign in to an app with a HUAWEI ID, Auth Service has to obtain the UnionID from the account. However, if you have not enabled the UnionID for your app, it will not be obtainable.
To enable the UnionID:
Sign in to HUAWEI Developers with your developer account.
Click Console and
go to App services > Development >HUAWEI ID.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click Update in the Operation column for the app. Then select Enable for UnionID.
Error code: 203818033 Error message: google response aud not equal to appidThis error occurs when we integrate Google account authentication. This is because the value of the aud parameter carried by the ID token is not the same as the app’s ID in Google. According to the Google’s official documents, the value of aud should be equal to the app’s ID specified by Client ID on Google Cloud Platform.
The aud parameter is the client ID in the Google account management console.
To resolve this problem, configure the app’s client ID to Client ID when you enable Google authentication mode in AppGallery Connect.
Does it Use oAuth 2.0?
Useful Sharing, thanks!