OAuthBrowser
This module will let you authenticate OAuth 2.0 via system browser and get response URL. Currently supporting Google Chrome and Safari browsers. Built with applescript and osascript, only works on Mac OSX.
A lot more can be done with OAuthBrowser like getting source code without getting automation detection from websites.
Installation
Use the package manager pip to install OAuthBrowser.
pip install OAuthBrowser
Or install the latest repo from here.
pip install git+https://github.com/Saadmairaj/OAuthBrowser#egg=OAuthBrowser
Usage
Usage is very simple
- Pass authentication URL.
- Apply
Waitclass to wait for the browser to redirect. - Fetch URL.
- Close browser.
from OAuthBrowser import Safari, Wait
from urllib.parse import urlparse, parse_qs
URL = """https://accounts.google.com/signin/oauth/oauthchooseaccount?
scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&
state=state_parameter_passthrough_value&
redirect_uri=https%3A%2F%2Foauth2.example.com%2Fcode&
access_type=offline&
response_type=code&
client_id=583306224539-atbcaa8ne8g85e8kc006o6vmq99qiid0.apps.googleusercontent.com&
o2v=2&as=CDdm3G6Zd1UOG9o_gWXzQQ&flowName=GeneralOAuthFlow"""
# Initialise browser
browser = Safari(window_geometry=(100, 22, 400, 690))
# Pass Authentication URL
browser.open_new_window(URL)
# Initialise Wait
wait = Wait(browser)
# Wait till query "code" is present in the URL.
wait.until_present_query('code')
# Fetch the url
response_url = urlparse(browser.get_current_url())
code = parse_qs(response_url.query).get('code')[0]
print("\nCode: %s\n" % code)
# Close the browser
browser.quit()
Demonstration
python -m OAuthBrowser
Contributing
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method of this repository before making a change.
Please make sure to update tests as appropriate.
License
Changelog
- 0.0.1
- First import.
Metadata
Release files for OAuthBrowser 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| OAuthBrowser-0.0.1.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| OAuthBrowser-0.0.1-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 13.8 kB
Release files / OAuthBrowser-0.0.1.tar.gz
| Download URL | OAuthBrowser-0.0.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66794fd4920f8c9040b7de886df3c4459f880efbfce50f2651672c7d58635876
|
|
BLAKE2b-256 checksum How to use checksums |
16165578502a71046d760799b8da4361a256e3e25929c7c10de9de8383cb8368
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8
|
Release files / OAuthBrowser-0.0.1-py2-none-any.whl
| Download URL | OAuthBrowser-0.0.1-py2-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
10ddeef9a151e69656cabfb6618288c001d923f532eda72f008946294ecd973b
|
|
BLAKE2b-256 checksum How to use checksums |
3d9cb9f019e52225d796bb931b73216f265fc1f8e16699c76cb8f77875b57112
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8
|