Key hash doesn't match while facebook login in android

前端 未结 9 1797
谎友^
谎友^ 2020-12-03 07:41

My app uses a simple facebook login. I have entered the keyhash in my app dashboard, key_hash section and I was able to login successfully. Now I have published the app and

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 08:27

    You can generate a hash key through coding, you simply do one thing. Paste this code in main class (first class) then run the app and check the logcat where you will find the hash key.

    One more thing, replace this package name "com.example.creeper" with your package name:

    try{
            PackageInfo info = getPackageManager().getPackageInfo(
                    "com.example.creeper", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:",Base64.encodeToString(md.digest(), Base64.DEFAULT));       
    
            }
        } catch (NameNotFoundException e) {
    
        } catch (NoSuchAlgorithmException e) {
    
    }
    

提交回复
热议问题