oauth2middleware / facebook
Facebook OAuth2 security middleware for routes.
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.5
- guzzlehttp/guzzle: ^6.3
This package is not auto-updated.
Last update: 2025-06-19 12:55:12 UTC
README
Laravel package for securing API's with Facebook's OAuth2 service.
OAuth2Middleware-Facebook works by verifying that each request sent to your server has an authorization token in the request Authentication
header. After verifying that there is an authorization token available, it validates it against Facebook's Graph API. This validation has two steps; verifying that the token given belongs to Facebook, and verifying that the token belongs to YOUR Facebook application.
You will need to setup an application in Facebook as well as retrieve a non-expiring OAuth2 application token. (See configuration)
Installation
Install with composer: composer require oauth2middleware/facebook
Configuration
The middleware requires two environment variables. (FB_APP_TOKEN
and FB_APP_ID
)
The FB_APP_TOKEN
environment variable refers to a non-expiring application token which belongs to YOUR Facebook application.
Follow the instructions here to retrieve a Facebook app token.
The FB_APP_ID
is your Facebook application's app Id. This can easily be found in the Facebook developer console.
Usage
The middleware alias is 'fb.auth'.
To use, use the middleware
function on the routes that you want to protect.
For example...
Route::middleware('fb.auth')->get('/secure_route', function (Request $request) {
// Your code...
return { your_response_variable };
});