Key hash for Android-Facebook app

后端 未结 30 2685
误落风尘
误落风尘 2020-11-22 01:17

I\'m working on an Android app, in which I want to integrate a Facebook posting feature. I downloaded the Facebook-Android SDK, and I got the readme.md (text file) in there,

相关标签:
30条回答
  • 2020-11-22 01:32

    For Linux

    Open Terminal :

    For Debug Build

    keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
    

    you wil find debug.keystore from ".android" folder copy it from and paste on desktop and run above command

    For release Build

    keytool -exportcert -alias <aliasName> -keystore <keystoreFilePath> | openssl sha1 -binary | openssl base64
    

    NOTE : Make sure In Both case it must ask for password. If it does not asks for password that means something is wrong in command.

    0 讨论(0)
  • 2020-11-22 01:33

    Here are the steps-

    1. Download openssl from Google code (If you have a 64 bit machine you must download openssl-0.9.8e X64 not the latest version)

    2. Extract it. create a folder- OpenSSL in C:/ and copy the extracted code here.

    3. detect debug.keystore file path. If u didn't find, then do a search in C:/ and use the Path in the command in next step.

    4. detect your keytool.exe path and go to that dir/ in command prompt and run this command in 1 line-

      $ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64

      • it will ask for password, put android
      • that's all. u will get a key-hash

    For more info visit here

    0 讨论(0)
  • 2020-11-22 01:33

    Solved mine too in Android Studio but with slight different approach.

    To get the SHA-1 value in Android Studio.

    1. Click Gradle
    2. Click Signing Report
    3. Copy SHA-1

    1. SHA-1 value look like this CD:A1:EA:A3:5C:5C:68:FB:FA:0A:6B:E5:5A:72:64:DD:26:8D:44:84

      and open http://tomeko.net/online_tools/hex_to_base64.php to convert your SHA1 value to base64. This is what Facebook requires get the generated hash " ********************= " and copy the key hash to the facebook app console.

    Part of this answer taken from here Github Link

    0 讨论(0)
  • 2020-11-22 01:38

    This is what is given at the official page of Facebook:

       keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
    

    Let me break this command into fragments.

    1. Look for "keytool.exe". You can search that on the C: drive. You can find it in "java jdk" or "java jre". If you have installed multiple versions, choose any.

    2. Open a CMD prompt and go to the above directory where you found "keytool.exe".

      Clip the "exe`" and paste the above command provided on the Facebook page.

    3. You will get an error on entering this that OpenSSL is not recognized as in input output command. Solution : Download "Openssl" from OpenSSL (if you have a 64-bit machine you must download openssl-0.9.8e X64). Extract and save it anywhere... I saved it on the C: drive in the OpenSSl folder

    4. Replace the openssl in the above command in which you was getting an error of OpenSSL with "C:\OpenSSL\bin\openssl" at both the places after the pipe, "|".

    5. If prompted for a password, enter android.

    And you will get your hash key. For further steps, refer again to the Facebook page.

    0 讨论(0)
  • 2020-11-22 01:38

    You can get key hash from SHA-1 key. Its very simple you need to get your SHA-1(Signed APK) key from Play Store check below image.

    Now Copy that SHA-1 key and past it in this website http://tomeko.net also check below image to get your Key Hash.

    0 讨论(0)
  • 2020-11-22 01:38

    try this :

    • two way to get Hash Key Value

    1) get hash key from using command line (Official Doc : https://developers.facebook.com/docs/android/getting-started)

    keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl
    base64
    

    OR

    2) get hash key using code

      @Override
       protected void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.activity_main);
    
                //Hask Kay generation 
                 GetKeyHase();
        }
    
        private void GetKeyHase() {
                try {
                    PackageInfo info = getPackageManager().getPackageInfo("ADD YOUR PACKAGE NAME", PackageManager.GET_SIGNATURES);
                    for (Signature signature : info.signatures) {
                        MessageDigest md = (MessageDigest.getInstance("SHA"));
                        md.update(signature.toByteArray());
                        String hashkey_value = new String(Base64.encode(md.digest(), 0));
                        Log.e("hash key", hashkey_value);
                        //check you logcat hash key value
                    }
                }catch (Exception e) {
                    Log.e("exception", e.toString());
                }
            }
    
    0 讨论(0)
提交回复
热议问题