Skip to main content
# BitlyOAuth2ProxySession

This is a simple subclass of `requests.Session` which, when initialized,
or when you call its `authenticate()` method, does the magic to talk to
the Bitly OAuth2 Proxy and return a session that is authenticated for
whatever is behind it.

The use case here is a read-only service user, which does not require
two-factor authentication, that you want to be able to access resources
behind the Bitly proxy. Our _particular_ use case right now is for a
monitoring system to be able to check on web pages that require
authentication. There's one class, the imaginatively-named `Session`.

## Installation

`pip install bitly-oauth2-proxy-session`

Or check out the repository, `cd` to its root directory, and `python
setup.py install`. It requires a fairly recent `requests` (2.8.1 or
later).

## Instance Attributes

* `oauth2_username`: a string containing the username of the underlying
OAuth2 user.
* `oauth2_password`: a string containing the password of the underlying
OAuth2 user. At least for GitHub, you can't use an auth token. The
reason behind this seems to be that this is what you'd do if you were
an actual user with an actual web browser. Yes, this means 2FA isn't
currently supported.
* `authentication_base_url`: a string containing the `start` URL of your
oauth proxy. Typically, _site_`/oauth2/start`.
* `authentication_session_url`: a string containing the URL of the page
you POST to when you create a session with the underlying OAuth2
source as a web user. For Github, this is
`https://github.com/session` and that's the default.
* `authentication_postdata`: a Python dict containing the data you need
to POST to the session URL. Defaults to the right thing for Github.

## Methods

* `[get_/set_]*()`: getters and setters for the various instance
attributes. No, you can't get the password this way.
* `authenticate()`: run the authentication dance and store the magic in
the session object.

## Usage

* Acquire a `Session` object.
* For Github, create the object with `oauth2_username`,
`oauth2_password`, and `authentication_session_url`.
* For something else (untested), create the object empty, set all the
fields via the setter methods, and then run `authenticate()`. Pull
requests welcomed.
* Do sessiony things, like `get()` and `post()`.

## Bugs

* If anyone knows how I can get a session with a Github user token
rather than a password, that'd be great.
* Github is the only working use case right now.




Metadata

Release files for bitly-oauth2-proxy-session 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bitly-oauth2-proxy-session 0.1.5
File Size Uploaded
bitly-oauth2-proxy-session-0.1.5.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bitly-oauth2-proxy-session 0.1.5
File Interpreter ABI Platform
bitly_oauth2_proxy_session-0.1.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 10.3 kB

Release files / bitly-oauth2-proxy-session-0.1.5.tar.gz

Download URL bitly-oauth2-proxy-session-0.1.5.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
54d5db83fc681a95a4e8309233c939ad54bee4ebe4bdd2cb7c6ebfdc60492c0d
BLAKE2b-256 checksum
How to use checksums
a2b5d9ba2d3462762522bd475ac264959c897cbe773be05dab186ded4d87647d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / bitly_oauth2_proxy_session-0.1.5-py2.py3-none-any.whl

Download URL bitly_oauth2_proxy_session-0.1.5-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
43706718042687f8a3a6fd4e34b87a513e38ad603c10fbd02f4edaa1f7fdf0f0
BLAKE2b-256 checksum
How to use checksums
05edeaa369f6fc3898f9e8783b99769ef965082d7c0a52506860a553c127b08c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page