[Android] Resolving Kakao API hash key error


Writing time : 2016-04-14 00:05:23

Resolving Kakao API hash key error

While creating an account on https://developers.kakao.com and linking the Kakao API, an error occurred that Haashiki was incorrect.

com.kakao.util.exception.KakaoException: AUTHORIZATION_FAILED :  
invalid android_key_hash or ios_bundle_id or web_site_url  

The reason is that in order to use the Kakao API, the key hash is registered as follows, but the set hash is not the same as the APK's hash.

Registered Kakao api application Hashiki

I installed openssl by referring to the development guide and extracted the keytool, but the same error occurred.

When I looked for the cause, it seems that the hashing value is generated differently depending on the openssl version.

To solve the problem, there was no error when the keytool was not used, but the hassiki was extracted directly using the Android SDK's PackageManager.

Hashing extraction using PackageManager Refer to the code below.

// Add code to print out the key hash  
try {  
PackageInfo info = getPackageManager().getPackageInfo(  
getPackageName(), PackageManager.GET_SIGNATURES);  
for (Signature signature : info.signatures) {  
MessageDigest md = MessageDigest.getInstance("SHA");  
md.update(signature.toByteArray());  
Log.e("MY KEY HASH:",  
Base64.encodeToString(md.digest(), Base64.DEFAULT));  
}  
} catch (NameNotFoundException e) {  
  
} catch (NoSuchAlgorithmException e) {  
  
}  

The code source is stackoverflow.com.

http://stackoverflow.com/questions/17423870/is-there-any-way-to-get-key-hash-from-signed-apk

Previous post