ron*_*nen 5 android accountmanager firebase firebase-authentication
我想使用 Firebase 构建一个 Android 应用程序。Firebase 为登录屏幕https://github.com/firebase/firebase-login-demo-android提供演示代码。
但不是让用户输入他们的帐户信息,我希望用户能够使用用户已经在 Android 的集中式帐户管理器中输入的帐户信息。
我见过的文档AccountManager对象在https://developer.android.com/reference/android/accounts/AccountManager.html和火力地堡在Android现身认证指南https://www.firebase.com/docs/android/ guide/user-auth.html,但我太菜了,不知道如何把它们放在一起。
任何建议/指针/示例代码将不胜感激。或者让我知道我是否在吠错树。
Firebase 工程师在这里,
这是一种完全合法的方式——过去我们已经有很多人选择整合它。
简短的回答是,它需要两个步骤:
看起来这是第一步(了解 AccountManager)的好资源。然后在 doCoolAuthenticatedStuff() 中,您将遵循我们典型的身份验证流程:
Firebase ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.authWithOAuthToken("google", "<OAuth Token>", new Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
// the Google user is now authenticated with your Firebase app
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
// there was an error
}
});
Run Code Online (Sandbox Code Playgroud)
对于 Google,我们使用“电子邮件”范围,但每个提供商都会有所不同。
我有一个在 iOS 世界中类似的例子(使用 ACAccountStore 登录 Twitter,这与 Android AccountManager 非常相似),如果流程有帮助的话。
这听起来像是一个很好的食谱/要点,所以我会看看我能做什么!
| 归档时间: |
|
| 查看次数: |
1913 次 |
| 最近记录: |