firebase登录验证_Firebase身份验证Facebook我

本文介绍了如何使用Firebase进行身份验证,特别是聚焦于通过Facebook账号进行登录验证的流程。内容涉及Firebase认证设置和Facebook登录集成。
摘要由CSDN通过智能技术生成

firebase登录验证

Firebase Authentication is a tool for managing user identity in a Firebase project. It provides a lot of authentication methods, including email/password, phone number and Facebook, etc. Facebook login is a very common option in modern app. App can benefit a lot by implementing Facebook login feature.

˚Firebase认证是在火力地堡项目管理用户身份的工具。 它提供了很多身份验证方法,包括电子邮件/密码电话号码和Facebook等。Facebook登录是现代应用程序中非常常见的选项。 通过实现Facebook登录功能,应用程序可以受益匪浅。

Image for post

Developer has to first create both the Firebase and Facebook project in order to complete the authentication process. The step for implementing the whole feature is as short as 9 steps. Let’s start!

开发人员必须先创建FirebaseFacebook项目,才能完成身份验证过程。 实现整个功能的步骤仅需9个步骤。 开始吧!

程序 (Procedures)

1.项目初始化 (1. Project initialisation)

Create a Firebase project at Firebase Console and a Facebook project at Facebook Developer Console.

Firebase控制台上创建一个Firebase项目,并在Facebook Developer Console上创建一个Facebook项目。

2.启用Facebook登录方法 (2. Enable Facebook Sign-In method)

Image for post

Navigate to the “Sign-in method” tab of “Authentication” session and enable the Facebook Sign-In method.

导航到“身份验证”会话的“登录方法”选项卡,然后启用Facebook登录方法。

Image for post

The App ID can be found at the Facebook Developer Console here:

可以在以下Facebook开发者控制台中找到该应用程序ID

3.将OAuth重定向URI复制到Facebook项目设置 (3. Copy the OAuth redirect URI to Facebook Project settings)

Image for post

4. Firebase项目设置 (4. Firebase project setup)

Link your iOS app to Firebase project with the use of GoogleService-Info.plist , which is a file generated during your app registration and containing important information, e.g. PROJECT_ID , BUNDLE_ID and API_KEY .

使用GoogleService-Info.plist将iOS应用程序链接到Firebase项目,该文件是在应用程序注册期间生成的文件,其中包含重要信息,例如PROJECT_IDBUNDLE_IDAPI_KEY

Image for post
GoogleService-Info.plist must be added to your target
必须将GoogleService-Info.plist添加到您的目标中

5.添加Firebase身份验证依赖项 (5. Adding Firebase Authentication dependency)

Firebase Authentication SDK can be added by CocoaPods. Include pod 'Firebase/Auth' in Podfile and run pod install afterward.

Firebase身份验证SDK可以由CocoaPods添加。 在Podfile包含Podfile pod 'Firebase/Auth' ,然后运行pod install

6.初始化Firebase SDK (6. Initialise Firebase SDK)

Initialise the Firebase configuration at the AppDelegate.swift file at the start of the app, see line 8.

在应用程序启动时,通过AppDelegate.swift文件初始化Firebase配置,请参阅第8行。

7.实施Facebook登录SDK (7. Implement Facebook login SDK)

Image for post

Facebook provides an easy to use login SDK for user to login and grant permission for app to retrieve his/ her personal information. Either SDK default login button or custom button can be used to trigger login function. Default login button is easier to be implemented.

Facebook提供了易于使用的登录SDK,供用户登录并授予应用程序检索其个人信息的权限。 SDK默认登录按钮或自定义按钮均可用于触发登录功能。 默认登录按钮更易于实现。

Make sure the loginButton(_: didCompleteWith: error:) of LoginButtonDelegate is implemented correctly such that the successful login callback can be caught and Firebase Authentication process (next step) can be called consecutively.

确保正确实施loginButton(_: didCompleteWith: error:)loginButton(_: didCompleteWith: error:)LoginButtonDelegate可以捕获成功的登录回调,并可以连续调用Firebase身份验证过程(下一步)。

8.使用Facebook访问令牌登录Firebase (8. Sign-in Firebase with Facebook access token)

After successfully logging in through Facebook SDK, an AccessToken is generated. The tokenString property can be used to identify a user. Firebase Auth SDK would use this to create a user at Firebase database.

通过Facebook SDK成功登录后,将生成一个AccessTokentokenString属性可用于标识用户。 Firebase Auth SDK将使用它来在Firebase数据库中创建用户。

9.验证Firebase用户已创建 (9. Verify Firebase user is created)

Image for post

After all process, new user data should be shown at the “Users” tab of the “Authentication” session.

完成所有过程后,应在“身份验证”会话的“用户”选项卡上显示新的用户数据。

Image for post

摘要 (Summary)

  1. Firebase provides Facebook Authentication option to create a user account with Facebook access token.

    Firebase提供了Facebook身份验证选项,以创建具有Facebook访问令牌的用户帐户。
  2. Developer has to create both the Firebase and Facebook project at the developer consoles first. The Facebook Sign-In option must be enabled at the Firebase Console.

    开发人员必须首先在开发人员控制台上创建Firebase和Facebook项目。 必须在Firebase控制台上启用Facebook登录选项。
  3. Developer has to first implement the Facebook Login SDK and capture the login success callback in the LoginButtonDelegate.

    开发人员必须首先实现Facebook Login SDK,并在LoginButtonDelegate捕获登录成功回调。

您可能想要 (You probably would like)

Image for post

You are welcome to follow me at Twitter@myrick_chow for more information and articles. Thank you for reading this article. Have a nice day! 😄

欢迎您通过Twitter @ myrick_chow关注我,以获取更多信息和文章。 感谢您阅读本文。 祝你今天愉快! 😄

翻译自: https://itnext.io/firebase-authentication-facebook-i-93aaf489839d

firebase登录验证

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值