How to verify Huawei ID on the server side using PHP

184 views Asked by At

On the Android App, I managed to retrieve the token using AGConnectAuth. Now I would like to verify that token on the server-side using PHP. Any idea?

I tried call https://oauth-login.cloud.huawei.com/oauth2/v3/tokeninfo with the param id_token=eyJhbGciOiJQUzI1NiIsImtpZCI6IXXX and it's returning the following error:

{
    "sub_error": 14004,
    "error_description": "",
    "error": 1400
}
2

There are 2 answers

0
Martin Zeitler On

Since the returned error code cannot be explained by the documentation ...
you may not be posting as content-type application/x-www-form-urlencoded;
most of the other API do require posting as application/json;charset=UTF-8.

I'm working on it, but don't have the that particular method implemented yet.
Maybe check within the next 1-2 weeks; I'm going to implement that anyway.

0
Zinna On

Your ID Token looks quite a bit shorter than the example show in the documentation (2nd link) that has over 1000 characters. I recommend checking if your POST request was formatted correctly with the mandatory parameters and making sure your headers are correct.

Obtaining an Access Token https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/account-obtain-token_hms_reference-0000001050048618 Once you have the correct ID token, here's the process to verify your token.

Verifying an ID Token https://developer.huawei.com/consumer/en/doc/development/HMSCore-References/account-verify-id-token_hms_reference-0000001050050577

Please share your PHP code and POST request so to help further if needed.