Android Google和facebook三方登陆遇到的坑
1.facebook
Facebook登录官方指导文档:https://developers.facebook.com/docs/facebook-login/android/
facebook三方登录要想正常使用,需要满足以下几点:
-
应用及sdk配置
image.png -
应用模式由开发模式改为上线模式,否则就只能测试用户能正常使用
image.png
要想改为上线模式需要填一些产品信息,完善一下就可以了。
-
最后一点最坑的是要获取高级访问权,否则app调起后会报错【Feature Unavailable: Facebook Login for this app is currently
unavailable, as this app does not have Advanced Access to
public_profile permission.】
image.png - 如果一直报秘钥散列错误可以考虑使用下边代码拿到应用的秘钥散列,然后配置在facebook的后台
try {
val info = packageManager.getPackageInfo(
BuildConfig.APPLICATION_ID, //Insert your own package name.
PackageManager.GET_SIGNATURES
)
for (signature in info.signatures) {
val md: MessageDigest = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT))
}
} catch (e: PackageManager.NameNotFoundException) {
} catch (e: NoSuchAlgorithmException) {
}
2.Google
Google登录官方指导文档:https://developers.google.com/identity/sign-in/android/sign-in
参考这篇博客文章:https://blog.csdn.net/u010976213/article/details/112893637
google登录还好,照着官方文档走就行
3.上架GooglePlay后登录报错
上架后由于签名被google改掉了,参考这里:https://blog.csdn.net/m0_37698386/article/details/106289041
具体还是记一下吧,省的人家的链接一旦失效就麻烦了
openssl下载地址:
https://code.google.com/archive/p/openssl-for-windows/downloads
https://console.developers.google.com/apis/credentials