Coder Social home page Coder Social logo

joeyism / py-oauth2_facebook_login Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 0.0 7 KB

Gets OAuth2 access token from Facebook automatically (with webdriver) using requests_oauthlib

License: Other

Python 100.00%
oauth2-access requests-oauthlib oauth2-facebook-login oauth2 facebook webdriver chromedriver chrome

py-oauth2_facebook_login's Introduction

oauth2_facebook_login

Gets OAuth2 access token from Facebook automatically from a webdriver, using requests_oauthlib

I developed this when I found that I needed to get data from Facebook API automatically, but there was always the human entry for OAuth2 flow. This library takes care of that with your selected webdriver

Installation

pip3 install --user oauth2_facebook_login

Usage

With Default Chrome Webdriver

First, setup Chrome Webdriver so that it is in PATH, which can be done in terminal

export PATH=$PATH:/home/username/Downloads/chromedriver

Then in Python, run

from oauth2_facebook_login import get_access_token

auth = get_access_token(
    email = "[email protected]",
    password = "password",
    client_id="1234567",
    client_secret="a1b2c3d4e5",
    scope = [
            "pages_show_list",
            "manage_pages",
            "pages_manage_instant_articles",
            "pages_manage_cta",
            "ads_management",
            "business_management"
            ]
    )

auth.access_token # Facebook access token

With Custom Webdriver

from oauth2_facebook_login import get_access_token
from selenium import webdriver

driver = webdriver.Chrome("/home/username/Downloads/chromedriver")

auth = get_access_token(
    email = "[email protected]",
    password = "password",
    client_id="1234567",
    client_secret="a1b2c3d4e5",
    scope = [
            "pages_show_list",
            "manage_pages",
            "pages_manage_instant_articles",
            "pages_manage_cta",
            "ads_management",
            "business_management"
            ],
    driver = driver
    )

auth.access_token # Facebook access token

With Custom Webdriver Headlessly

from oauth2_facebook_login import get_access_token
from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('headless')
chrome_options.add_argument('no-sandbox')

driver = webdriver.Chrome("/home/username/Downloads/chromedriver", chrome_options = chrome_options)

auth = get_access_token(
    email = "[email protected]",
    password = "password",
    client_id="1234567",
    client_secret="a1b2c3d4e5",
    scope = [
            "pages_show_list",
            "manage_pages",
            "pages_manage_instant_articles",
            "pages_manage_cta",
            "ads_management",
            "business_management"
            ],
    driver = driver
    )

auth.access_token # Facebook access token

Versions

1.0.x

  • First Publish

py-oauth2_facebook_login's People

Contributors

joeyism avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.