2

I follow this article https://forums.developer.huawei.com/forumPortal/en/topic/0204412554756330223 to do the HMS account kit plug-in. This is the expected result.

enter image description here

It supposed to pop out the huawei ID page after I clicked the Huawei Sign In.

But it just remain at the sign in page. and pop out a lot of log that I couldn't understand.

This is the logs.

logs message

import 'package:flutter/material.dart';
import 'package:huawei_account/huawei_account.dart';
import 'package:sign_in_hms/home.dart';

void main() {
   runApp(MyApp());
 }
  
 class MyApp extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return MaterialApp(
       title: 'AccountKit',
       theme: ThemeData(
         primarySwatch: Colors.blue,
         visualDensity: VisualDensity.adaptivePlatformDensity,
       ),
       home: MyHomePage(title: 'Account Kit'),
     );
   }
 }
  
 class MyHomePage extends StatefulWidget {
   MyHomePage({Key key, this.title}) : super(key: key);
   final String title;
  
   @override
   _MyHomePageState createState() => _MyHomePageState();
 }
  
 class _MyHomePageState extends State<MyHomePage> {
   List<String> logs = [];
  
   @override
   Widget build(BuildContext context) {
     return Scaffold(
       appBar: AppBar(
         title: Text(widget.title),
       ),
       body: new Stack(
         fit: StackFit.expand,
         children: <Widget>[
           new Image(
             image: new AssetImage("assets/images/mobile.png"),
             fit: BoxFit.cover,
           ),
           new Form(
               child: new Container(
             padding: const EdgeInsets.all(60.0),
             child: new Column(
               mainAxisAlignment: MainAxisAlignment.center,
               children: [
                 new TextField(
                   decoration: new InputDecoration(
                       labelText: "Enter Email", focusColor: Colors.white),
                   keyboardType: TextInputType.emailAddress,
                 ),
                 new TextField(
                   decoration: new InputDecoration(labelText: "Enter Password"),
                   keyboardType: TextInputType.text,
                 ),
                 new Padding(
                   padding: const EdgeInsets.only(top: 20.0, bottom: 20.0),
                 ),
                 new MaterialButton(
                   minWidth: 100.0,
                   height: 40.0,
                   onPressed: () => {print('object')},
                   color: Colors.red,
                   textColor: Colors.white,
                   child: Text("LOGIN", style: TextStyle(fontSize: 20)),
                 ),
                 new Padding(
                   padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
                 ),
                 Text(
                   '( OR )',
                   textAlign: TextAlign.center,
                   overflow: TextOverflow.ellipsis,
                   style: TextStyle(
                       fontWeight: FontWeight.bold,
                       color: Colors.white,
                       fontSize: 15),
                 ),
                 new Padding(
                   padding: const EdgeInsets.only(top: 10.0, bottom: 10.0),
                 ),
                 new MaterialButton(
                   child: Text(
                     " HUAWEI SIGN IN",
                     style: TextStyle(fontSize: 20),
                   ),
                   minWidth: 100.0,
                   height: 40.0,
                   onPressed: _onSinIn,
                   color: Colors.red,
                   textColor: Colors.white,
                   padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
                 )
               ],
             ),
           ))
         ],
       ),
     );
   }
  
   void _onSinIn() async {
     AccountAuthParamsHelper authParamHelper = new AccountAuthParamsHelper();
     authParamHelper
       ..setIdToken()
       ..setAuthorizationCode()
       ..setAccessToken()
       ..setProfile()
       ..setEmail()
       ..setScopeList([Scope.openId]);
     try {
       final AuthAccount accountInfo = await AccountAuthService.signIn(authParamHelper);
       setState(() {
         Navigator.push(
           context,
           MaterialPageRoute(
               builder: (context) => Home(accountInfo)),
         );
         _showToast(context);
         logs.add(accountInfo.displayName);
       });
     } on Exception catch (exception) {
       print(exception.toString());
       logs.add(exception.toString());
     }
   }
  
   void _showToast(BuildContext context) {
     final scaffold = Scaffold.of(context);
     scaffold.showSnackBar(
       SnackBar(
         content: const Text('Successfully Loged In'),
         action: SnackBarAction(
             label: 'UNDO', onPressed: scaffold.hideCurrentSnackBar),
       ),
     );
   }
 }
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
kiku
  • 147
  • 1
  • 10

1 Answers1

1

Ensure that the device and cloud configurations of the certificate fingerprint are consistent. The certificate packaged by the client application is the same as the SHA256 certificate fingerprint configured for the application on the AppGallery Connect website.

  1. Verify that the certificate fingerprint is correctly configured when you apply for related services. Open the APK file of an app, extract the META-INF directory from the file, obtain the CERT.RSA file in the directory, and run the keytool -printcert -file META-INF/CERT.RSA command to record the signing certificate information.

  2. Sign in to AppGallery Connect, click My projects, and select a required project. On the displayed page, select the app, go to Project settings > General information, and check whether the value in SHA-256 certificate fingerprint is the same as that in step 1.

In addition, HMS Core (APK) will cache the signature file. You need to find HMS Core (APK) on the Apps page of your device and clear its cache, restart your app, and perform the previous operation again.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Sorry, I'm still new to this. I not really sure how to perform the step 1. where should I locate the META-INF and CERT.RSA file – kiku Aug 03 '21 at 08:24
  • hi@kiku, about that you can refer to this [Docs](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/config-agc-0000001050196065). – zhangxaochen Aug 04 '21 at 01:57