Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Need more help? Go to Stack Overflow.
Yes, certainly. It is a common scenario.
The AppAuth SDK will help you achieve what you want. For details, please refer to For Android Apps.
The answer is certainly yes.
Though the user signs out, the HUAWEI ID is actually still in signed-in state on your app, because the user has authorized your app. Therefore, it's normal that your app does not require input of account information from the user when he/she signs in again. The user has to enter necessary information for signing in, if he/she has done either of the following:
Full-screen adaptation is not made for a page in the Account SDK. To resolve this issue, do as follows:
- public void accountAuthSignIn() {
- AccountAuthParams authParams = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM).setAuthorizationCode().createParams();
- AccountAuthService service = AccountAuthManager.getService(MainActivity.this, authParams);
- Intent intent = service.getSignInIntent();
- intent.putExtra(CommonConstant.RequestParams.IS_FULL_SCREEN, true);
- startActivityForResult(intent, 8899);
- }
The lengths of access token and refresh token are related to the information encoded in the tokens. Currently, each of the two tokens contains a maximum of 1024 characters.
This API can be called by an app up to 10,000 times within one hour. If the app exceeds the limit, it will fail to obtain the access token.
Description
After integrating Account Kit, I call the /oauth2/v3/tokeninfo API of the Account Kit server to obtain the ID token, but can't find the email address in the response body.
The response in this case is as follows:
- {
- "at_hash": "XXXXXX",
- "aud": "XXXXXX",
- "sub": "XXXXXX",
- "azp": "XXXXXX",
- "kid": "XXXXXX",
- "iss": "https://accounts.huawei.com",
- "typ": "JWT",
- "exp": 1579682457,
- "display_name": "136******53",
- "iat": XXXXXX,
- "alg": "RS256"
- }
The response in the API reference is as follows:
- {
- "iss":"String",
- "sub":"String",
- "aud":"String",
- "exp":"Long",
- "iat":"Long",
- "nonce":"String",
- "at_hash":"String",
- "azp":"String",
- "email_verified":"Boolean",
- "email":"String",
- "picture":"String",
- "name":"String",
- "locale":"String",
- "family_name":"String",
- "given_name":"String",
- "display_name":"String"
- }
Possible Causes
Before obtaining the ID token, the app does not request the HUAWEI ID user to authorize the app to obtain the email address.
Procedure
In the client-side code of your app, call the related API to request the HUAWEI ID user to authorize the app to obtain the email address.
The authorization request API in Account SDK 3.0 is requestEmail(), and that in Account SDK 4.0 is setEmail().
- HuaweiIdSignInOptions mSignInOptions = new HuaweiIdSignInOptions.Builder(HuaweiIdSignInOptions.DEFAULT_SIGN_IN).requestServerAuthCode().requestIdToken("").requestEmail().build();
- HuaweiIdAuthParams authParams = new HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM).setIdToken().setEmail().createParams();
For details about how to request a HUAWEI ID user to authorize an app to obtain the email address, please refer to setEmail in HuaweiIdAuthParamsHelper.
No private key is required for verifying or parsing an ID token.
The minimum Android version for the ID token-based integration demo is Android 9. Check whether the Android version on the test phone is the required version.
The email address is not mandatory. Sign in to the account center to check whether the user's account information contains the email address.
The public key used to verify the ID token is updated once a day and can be cached on your app server. If the public key is invalid, obtain the latest public key from certs and update the public key cached on the app server.
No. For privacy protection, you can obtain only the OpenID and UnionID.
OpenID: Currently, the OpenID returned by the Account Kit server does not have a fixed length, but the maximum length allowed is 256 characters. For future expansion considerations, reserve at least 768 (256 x 3) characters for the OpenID. Actually, you are advised not to set any length limit for the OpenID.
UnionID: Currently, the UnionID returned by the Account Kit server consists of 46 characters, and the maximum length allowed is 64 characters. For future expansion considerations, reserve at least 192 (64 x 3) characters for the UnionID. Actually, you are advised not to set any length limit for the UnionID.
The difference between UnionID and OpenID lies in that if multiple apps are managed under the same developer ID, the OpenID varies depending on the apps, but the UnionID is the same for all the apps. If you need to share the user information of the same HUAWEI ID across different apps, use UnionID as the user ID.
The validity period of the access token is 1 hour, and that of the refresh token is 180 days.
In Android 11, the way for an app to query other apps on the user device and interact with them has been changed. If targetSdkVersion is 30 or later for your app and the Account SDK integrated into your app is earlier than 6.1.0.300, your app will be unable to access HMS Core (APK) and continuously ask users to update the APK.
You can solve the issue using either of the following methods:
Update the Account SDK to 6.7.0.300. See Version Change History for detailed version information.
If the SDK is not updated, add a <queries> element in the manifest element in AndroidManifest.xml.
- <manifest ...>
- ...
- <queries>
- <intent>
- <action android:name="com.huawei.hms.core.aidlservice" />
- </intent>
- </queries>
- ...
- </manifest>
The <queries> element requires the following: