Facebook Social Login with Magic
Facebook Social Login with Magic
#Overview
You can allow your users to sign up & login into your web application with their Facebook account.
#Usage
#Prerequisites
- You will need a Facebook Developer account
- You will need to have the Magic SDK installed into your web application
- You will need to have the Magic SDK - OAuth Extension installed into your web application
#Facebook Setup (v1 extension)
After installing the OAuth extension, you can now enable Facebook Login for your Magic application:
- Follow Facebook's instructions to register a Facebook application
- When creating your Facebook application, select Authenticate and request data from users with Facebook Login, click Next and follow the prompts to add app information
- On the next screen, you'll be presented with steps to customize your Facebook application. Click Customize adding a Facebook Login button.
- Go to your Magic Dashboard
- Select the Magic app for which you’d like to enable Facebook Login, or create a new application
- Navigate to Authentication -> Social Logins from the sidebar
- Click the toggle for Facebook
- Copy the Redirect URI field from your Magic Dashboard
- Back in your Facebook Login Settings, paste the Redirect URI in the Valid OAuth Redirect URIs input and save the changes
- From the main Facebook dashboard, click on App Settings -> Basic
- Copy the App Id and App Secret
- From the Magic Dashboard, add your App Id and App Secret to your Facebook Login configuration
- Click Save
- Click Test Connection to give your new Facebook OAuth flow a try!
#Facebook Setup (v2 extension)
- Follow above steps, but disregard Magic's Redirect URI in step 8
- In step 9, paste the Redirect URI you are passing in as the redirectURI argument to the loginWithRedirect method
Javascript
01await magic.oauth2.loginWithRedirect({
02 provider: 'facebook',
03 redirectURI: 'https://your-app.com/your/oauth/callback', // <== whitelist this with Facebook
04});