// check this link for different scopes: https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/independentsignin-0000001140395573 public void IndependentSignIn(string accessToken) { AccountAuthParams authParams = new AccountAuthParamsHelper().SetEmail().CreateParams(); AccountAuthService authService = AccountAuthManager.GetService(authParams); Debug.Log("[HMSAccountManager]: Independent Sign in "); authService.StartIndependentSignIn(accessToken, (success) => { Debug.LogWarning("[HMSAccountManager]: Independent Sign in Success. Auth Code: " + success.AuthorizationCode); OnIndependentSignInSuccess?.Invoke(success); }, (error) => { Debug.LogError("[HMSAccountManager]: Independent Sign in failed. CauseMessage: " + error.WrappedCauseMessage + ", ExceptionMessage: " + error.WrappedExceptionMessage); OnIndependentSignInFailed?.Invoke(error); }); }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == SignCode) { try { Task authAccountTask = AccountAuthManager.ParseAuthResultFromIntent(data); if (authAccountTask.IsSuccessful) { AuthAccount authAccount = (AuthAccount)authAccountTask.Result; Log.Info(TAG, "Huawei ID login success. Access token: " + authAccount.AccessToken); // Create Huawei Id credential IAGConnectAuthCredential credential = HwIdAuthProvider.CredentialWithToken(authAccount.AccessToken); // sign In SignIn(credential); } } catch (Java.Lang.Exception ex) { Log.Error(TAG, "Failed: " + ex.Message); } } else if (requestCode == 64206) { callBackManager.OnActivityResult(requestCode, (int)resultCode, data); } else if (requestCode == 9001) { Android.Gms.Tasks.Task task = GoogleSignIn.GetSignedInAccountFromIntent(data); task.AddOnSuccessListener(new GoogleSignInListener(this)); task.AddOnFailureListener(new GoogleSignInListener(this)); } else if (requestCode == 9003) { Android.Gms.Tasks.Task task = GoogleSignIn.GetSignedInAccountFromIntent(data); task.AddOnSuccessListener(new GooglePlaySignInListener(this)); task.AddOnFailureListener(new GooglePlaySignInListener(this)); } }