首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Firebase Auth进行身份验证时注销Facebook用户

使用Firebase Auth进行身份验证时注销Facebook用户
EN

Stack Overflow用户
提问于 2018-07-21 05:27:48
回答 1查看 962关注 0票数 1

我有以下代码,它先用Facebook验证用户身份,然后用Firebase验证用户身份:

代码语言:javascript
复制
func authenticateWithFacebook() {
    FBSDKLoginManager().logIn(withReadPermissions: ["public_profile"], from: self) { (user, error) in // Signs up user with Facebook
        if let error = error {
            print(error.localizedDescription)
        } else if (user!.isCancelled) { // User cancels sign up
            print("User Cancelled")
        } else {
            self.authenticateFacebookUserWithFirebase(credential: FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString))
        }
    }
}

func authenticateFacebookUserWithFirebase(credential: AuthCredential) {
    Auth.auth().signInAndRetrieveData(with: credential) { (user, error) in
        if let error = error {
            print(error.localizedDescription)
        } else {
            print("Success")
        }
    }
}

这段代码按预期工作。一旦用户通过了Firebase的身份验证,我该如何处理在应用程序中“创建”的Facebook用户?我是否需要跟踪currentAccessToken并在令牌过期时向Firebase身份验证发出警报?如果不是,我是只保留代码不变,还是应该使用FBSDK将Facebook用户从我的应用程序中注销?我只是不想让Facebook令牌在我的应用程序中四处漂浮。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-21 07:07:25

用户没有使用Facebook登录到Firebase。你的应用程序不会获得用户的facebook电子邮件和密码凭据,以便将他们登录到应用程序的Firebase。相反,它会获取该用户的访问令牌,然后使用该令牌向Firebase验证用户身份。因此,您不能从Facebook注销您的用户,但您可以做的是使访问令牌无效。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51450581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档