You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android应用Facebook登录遇Firebase无效hash key及debug_token失败问题求助

Fixing Facebook Login Issues on Android: Debug Token & Invalid Hash Key Problems

Hey there, let’s work through those frustrating Facebook Login bugs you’re hitting—these are super common, but easy to fix once you nail down the details!

1. Fixing "Facebook Login Unsuccessful debug_token response from Facebook"

Here are the most likely fixes for this error:

  • Verify your App ID/Secret & Token Validity
    Double-check that the App ID and App Secret in your Facebook Developer Dashboard match exactly what’s in your Android project (look for the com.facebook.sdk.ApplicationId meta-data in your AndroidManifest.xml). You can validate the debug token directly using Facebook’s Graph API:
    GET /debug_token?input_token={your_debug_token}&access_token={your_app_id}|{your_app_secret}
    
    The response will tell you if the token is expired, tied to the wrong app, or invalid for another reason.
  • Check Login Product Configuration
    In the Facebook Developer Dashboard, navigate to your app’s "Login with Facebook" product settings. Make sure:
    • The Valid OAuth Redirect URIs is set to fb{your_app_id}://authorize (replace {your_app_id} with your actual ID)
    • Required toggles like "Embedded Browser OAuth Login" are enabled (this is needed for in-app login flows)
  • Confirm SDK Initialization
    Ensure you’re initializing the Facebook SDK correctly in your Application class (or main activity):
    FacebookSdk.sdkInitialize(getApplicationContext());
    
    A missing or misconfigured initialization can cause token validation failures.

2. Fixing "Invalid hash key when trying to login using Facebook" (Both Debug & Release Scenarios)

Hash keys are tied to your app’s signing certificate—debug and release builds use different certificates, so you need to add both to Facebook’s dashboard.

For Android Studio-installed (Debug) Apps

  • Regenerate the Debug Hash Key
    Run this command in Android Studio’s Terminal (use the correct one for your OS):
    • Mac/Linux:
      keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
      
    • Windows:
      keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
      
    The default password is android. Copy the generated base64 hash and add it to your app’s "Android" platform settings in the Facebook Developer Dashboard under "Key Hashes".
  • Confirm Debug Keystore Path
    If you’ve customized your debug keystore, check the path in Android Studio via File > Project Structure > Modules > Signing Configs > Debug. Update the command above to use this custom path if needed.

For Play Store-installed (Release) Apps

  • Use Play App Signing Hash (If Enabled)
    Most apps use Google Play’s App Signing feature now. To get the correct hash:
    1. Open the Google Play Console, go to your app > Release > Setup > App signing
    2. Copy the SHA-1 certificate fingerprint from the "App signing certificate" section
    3. Convert this SHA-1 hex string to base64 (you can use a local command line tool or a simple converter script)
    4. Add this base64 hash to Facebook’s "Key Hashes" list
  • For Custom Release Keystores
    If you’re not using Play App Signing, generate the hash from your own release keystore with this command (replace placeholders):
    keytool -exportcert -alias {your_release_alias} -keystore {path_to_release_keystore} | openssl sha1 -binary | openssl base64
    
    Enter your keystore password when prompted, then add the resulting hash to Facebook’s dashboard.
  • Double-Check Package & Class Names
    In Facebook’s Android platform settings, ensure the Package Name matches exactly what’s in your AndroidManifest.xml, and the Class Name is the full path to your Login Activity (e.g., com.yourcompany.yourapp.LoginActivity).

内容的提问来源于stack exchange,提问作者Andrey Dobrikov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:02:08