This repo is a facebook authentication demo using Laravel 5.8 as the backend framework and SQLite as its database. Using ngrok to serve it online.
-
Install required prerequisites
- PHP 7.2
- Composer 1.10.1
- Ngrok
- Node and NPM
-
Cloning the repo
$ git clone [email protected]:lukaserat/laravel5.8-facebook-auth.git plannthat $ cd plannthat
-
Install App Dependencies
-
Install frontend dependencies
$ npm install $ npm run production
-
Install backend dependencies
$ composer install
-
-
Do Migration
$ touch database/database.sqlite $ php artisan migrate
-
Setup Environment file
$ cp .env.example .env
Update required environment variables after you setup your ngrok and facebook app
-
Generate Application Key
$ php artisan key:generate --ansi
-
Run your local instance
$ php artisan serve
For us to be able to comply with FB App security policy, we need to establish our app online. We will be using ngrok to serve our local instance.
See ngrok for documentation
Basically here are the steps:
- Register/Login to ngrok
- Locally run the app
$ php artisan serve
- Connect your account
$ ngrok authtoken your_ngrok_token
- Start ngrok to tunnel your local instance
$ ngrok http your_app_port
Once you have successfully serve your local instance online, update your Facebook App's url.
See this link to know how to create your own Facebook App.
Important things about setting up your facebook app.
- Privacy Policy URL = <your_ngrok_url>/privacy-policy example: https://164b5ddf.ngrok.io/privacy-policy
- App Domains = <your_ngrok_domain> example: 164b5ddf.ngrok.io
- Contact Email = <your_email>
- Product = Add "Facebook Login"
Facebook Login required settings:
- Valid OAuth Redirect URIs = <your_ngrok_url>/facebook/success example: https://164b5ddf.ngrok.io/privacy-policy/facebook/success
- APP_DOMAIN
- APP_EMAIL
- FB_CLIENT_ID
- FB_CLIENT_SECRET
- FB_URL