mirror of
https://github.com/zhigang1992/examples.git
synced 2026-01-12 17:13:21 +08:00
1.7 KiB
1.7 KiB
Facebook Auth Example
Check out the Auth with Facebook docs.
Try it at https://expo.io/@community/with-facebook-auth
How to use
Running the app
- Run
yarnornpm install - Run
expo start, try it out. - Press "Open FB Auth" in the app and then check your logs. Take the
redirectUrlthat was logged and enter it into the "Valid OAuth redirect URIs" in your Facebook app configuration step below.
Setting up the Facebook app
- Follow the steps described in the Facebook for Developers documentation
- Add the "Facebook Login" product and configure it (screenshot)
- Make the app public (screenshot)
- Swap out the
FB_APP_IDinApp.jswith your Facebook app's id.
The idea behind the example
Expo provides a
WebBrowser
API that opens a SFSafariViewController or Chrome Custom Tab in a modal
window. This provides a much better user experience than using a
WebView, and it's more secure for your users because code cannot be
injected into these browser windows. Additionally, they share cookies
with the system browser, so there is no need to re-enter credentials if
already authenticated. Expo also provides a wrapper around the WebBrowser
API which is called AuthSession,
which makes setting up an authentication flow using WebBrowser dead simple.
This example demonstrates how to use the AuthSession API to sign in to
Facebook.