Android Facebook SDK: generate release key hash

后端 未结 11 1922
执念已碎
执念已碎 2020-12-04 14:49

I\'m building an app in which users can log in with Facebook.

I\'ve created the hash keys like following:

try {
         PackageInfo info = getPackag         


        
相关标签:
11条回答
  • 2020-12-04 15:01

    For future reference, if you already have your app on Play Store you can this:

    1. Go to Release Management

    2. select App Signing in Release Management

    3. You can see SHA1 key in hex format App signing certificate.

    4. Copy the SHA1 in hex format and convert it in to base64 format, you can use this link http://tomeko.net/online_tools/hex_to_base64.php to do that without the SHA1: part of the hex.

    5. Go to Facebook developer console and add the key(after convert to base 64) in the settings —> basic –> key hashes.

    0 讨论(0)
  • 2020-12-04 15:01
    1. First open the command prompt (Windows + R)

    2. cd C:\Program Files\Java\jre1.8.0_172\bin

    3. Download openssl from HERE

    4. Create a folder named OpenSSL in C:/ drive

    5. Export the downloaded zip file in OpenSSL folder

    6. Generate the command as:-

      keytool -exportcert -alias YOUR_ALIAS -keystore "YOUR_KEYSTORE_PATH" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64

    7. Paste the command in command prompt and press enter

    8. Enter password

    9. Here you can see the key :- "1skdhyjsgd56whdjddV+vCLE="

    0 讨论(0)
  • 2020-12-04 15:02

    You followed the steps that facebook provides for the creation of a login application?

    You need a 'Production keyhash' obtained starting your release keystore:

    From comand line:

    keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
    

    And add this key on facebook app page options.

    More information: https://developers.facebook.com/docs/android/getting-started/

    0 讨论(0)
  • 2020-12-04 15:03

    // add this method to your first activity and open log and search for Base64 tag this is the Hashkey i hoop it help

    public void getHashkey(){
        try {
            PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
    
                Log.i("Base64", Base64.encodeToString(md.digest(),Base64.NO_WRAP));
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.d("Name not found", e.getMessage(), e);
    
        } catch (NoSuchAlgorithmException e) {
            Log.d("Error", e.getMessage(), e);
        }
    }
    
    0 讨论(0)
  • 2020-12-04 15:03

    Facebook SDK uses two different keys, one is Debug key which you can use during your development phase and other is Release key which is used once you create a signed application package. Here is a link about how to create debug and release keys.

    Developer.Facebook

    Also check out this SO post.

    0 讨论(0)
  • 2020-12-04 15:04

    The simplest solution.

    1) Sign your Apk.

    2) Connect your device to machine and Install signed apk on real device.

    3) When facebook login is pressed, you will get an error saying "Invalid key hash. The key hash "xxx" does not match any stored key. ..." on your logcat.

    4)Copy the logcat Hash Key and put this key to developers.facebook.com/apps/104...../settings/

    0 讨论(0)
提交回复
热议问题