Facebook Login SDK
(Download) is Python implementation of
Facebook Login Flow.
Login function can by used in any business application, that requires access to
Facebook Graph API.
In Facebook Login Flow access token can be obtained on behalf of authenticated user.
SDK opens Facebook login form in installed web browser. After successful authentication
browser is redirected to URL, that is passed in authentication request. Redirect URL
includes parameter, that is used by login SDK to fetch final access_token
. When
procedure ends, web browser is closed automatically.
Facebook Login SDK
doesn't have dependencies on any third party library.
You don't need any special installation procedure. Download sdk module and copy it to directory with your application.
Import module and execute function
get_standalone(
app_id,
app_secret,
browser='chrome',
redirect='https://example.com',
port=None,
incognito=False,
temp_profile=False
)
Pass Facebook Application App Id
and App Secret
. You will find these values in
App Dashboard.
By default function will try to open Facebook login form in Chrome browser in normal
mode and with default profile. After successful authentication user will be redirected
to https://example.com
. Any URL, that is passed in redirect
argument must be defined
in application settings. Otherwise Facebook will reject request.
If function end without exception it will return dictionary {'access_token': <str>, 'token_type': 'bearer', 'expires_in': <number> }
.
You can use value of access_token
in requests to Facebook Graph API.
SDK supports Python Logging framework. You can enable details log by settin DEBUG
level
in logging
module configuration
import logging
logging.basicConfig(level=logging.DEBUG)
SDK module contains example application, that can be run from command line. After
executing python3 fb_login.py
it will ask for App Id and App secret and pass it to
get_standalone
function.
Facebook Login SDK is distributed under GNU Affero General Public License. If you need commercial license contact me.
If you need commercial support or you want to report bug, you can send me message in contact form.