A Case Study of Resolving 403 Error During PMS API Call - Huawei Developers

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.

Related

What Can I Do If –1 Is Returned by the consumeOwnedPurchase API?

Symptom:
After I have integrated HUAWEI In-App Purchases (IAP), my app calls createPurchaseIntent to successfully purchase a product, and then calls consumeOwnedPurchase to consume the product after successful delivery. However, the product consumption fails, and result code –1 is returned.
Analysis
Refer to the description of the result code in the official documentation of HUAWEI IAP:
{
"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"
}
I called the API in the description, and then the API returned the order information. That is, the product in this order had not been consumed, and I needed to call an API to consume the product, based on the official documentation.
The description here indicates that if result code –1 is returned when I call the payment API, I need to check whether the order is missed. If so, the product needs to be delivered again.
Search for the keyword hms_pay in logs to check for the cause.
As I have communicated with Huawei technical support, the following information in red is the key to solve the problem:
It is found that the field length exceeds the upper limit.
Summary
If HUAWEI IAP-related result codes are returned, you can first refer to the result code description and then search for the hms_pay keyword in logs to view relevant information for fault locating. Thanks for your attention.

Error message "Token is expired or invalid" is displayed when I call the API for verifying the purchase token. What can I do?

Symptom​I integrated HUAWEI IAP into my app and called the relevant API to verify the payment order by referring to the official documentation, but the following error message was displayed:
{“responseCode”:”6",”responseMessage”:”Token is expired or invalid”}
Troubleshooting​I contacted Huawei technical support and they suggested me locating the problem by performing the following steps:
If the server is using development languages including Java, PHP, C#, Python, Node.js, Golang, Ruby, or Perl, check your code by referring to the sample code provided by Huawei.
When sending a request to Huawei server, you need to use the access token for authentication. Make sure to obtain the token in client credentials mode by referring to the documentation.
{
"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"
}
When you obtain the request parameter AccessToken, the app ID and app secret parameters are required. (This is where I got things wrong. I made a mistake when obtaining the app secret.) You can find the information here.
Ensure that app IDs for obtaining the purchase token to be verified from inAppPurchaseData and obtaining the access token are the same.

HUAWEI Game Service Sign-in Authentication Error: can not find publicKey of the cp

Symptom​When I called the API for verifying the sign-in signature provided by HUAWEI Game Service,
the following error was reported:
XML:
“rtnCode”:-1,”errMsg”:”can not find publicKey of the cp: 28500XXXXXXXXXXXX523"
Analysis​It seemed that this error was caused by a missing public key. However, when I checked the Game Service page for this app, I found that both the public key and private key were not missing.
{
"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"
}
Solution​I submitted a ticket to Huawei technical support and they told me that the problem was caused by incorrect cpId. The account we used to sign in to AppGallery Connect was a sub-account under the team account. Each sub-account has its own developer ID. However, cpId used in the API request must be the developer ID of the account holder in the team. The displayed developer ID can only be used as cpId when the signed in account is the account holder’s.
According to the official materials, cpId should be obtained from the downloaded agconnect-services.json file. The cp_id parameter in the JSON file is the same as the developer ID of the account holder, regardless of the signed in account. For details, please refer to Verifying the Sign-in Signature.
The problem was solved after we changed cpId in the request.

What should I do if test users cannot see my app on HUAWEI AppGallery after being redirected from an open testing invitation link?

During Open Testing, a test user accepted my invitation and was redirected to AppGallery, but they were unable to see the test version. The No longer available message was displayed. Why did this happen and what should I do?
Here’s what the page looks like.
{
"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"
}
There are three possible causes for this:
1. The test user has not signed in to AppGallery.
Solution: The user needs to sign in to AppGallery using the account you have invited.
2. The test user has signed in to AppGallery, but the signed-in account is not the account you have invited.
Solution: The user needs to switch to the invited account.
3. The registration site of the test account does not match the data storage location where the test user list was created. For example, the data storage location is the Germany site, but the test account belongs to a test list in Mexico. Even if the test user receives an invitation email, the app will not be available.
Solution: Create a new test user list and release another open testing version to the new list.
The preceding questions are included in the FAQs and video classes.
FAQs:
https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-betatest-faq
Open Testing troubleshooting video:
https://developer.huawei.com/consum...pGallery-connect-Guides/agc-betatest-faqvideo

What can I do if HUAWEI IAP reports error 60003 after I switched to some countries/regions?

Problem​I have integrated HUAWEI IAP to my project and configured a product. I opened AppGallery, went to Me > Settings > Country/Region, and set different countries/regions for testing. I discovered that if the country/region was China or Singapore, the payment was processed as normal, but when I switched to Albania, the payment failed and the error code 60003 was returned.
I searched for the keyword hms_pay in the logs and found the following information:
responseMessage = Product info cannot be found.
{
"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"
}
Cause​I checked the official materials and found only the following description.
My product did exist and the payment was processed as normal in both China and Singapore. It only failed in Albania.
After this, I submitted a ticket to Huawei technical support and they informed me that
HUAWEI IAP does not support Albania. They recommended that I check the official guide to learn about the countries/regions supported by HUAWEI IAP.
I hope this case can resolve any issues you may encounter when HUAWEI IAP does not work in some countries/regions.

Categories

Resources