Skip to main content

generic_oauth makes it extremely simple to use any OAuth v2 API purely from the command line.

Project description

# Generic Oauth

## Description

`generic_oauth` makes it extremely simple to use any OAuth v2 API purely from the command line. With any of the provided implementations you can get an access token in just 2 lines of code.

Typically browsers are a required component of the Oauth flow—APIs use html pages to allow users to grant permisson to third party apps to make requests on their behalf. This makes it easy for web-apps to use oauth apis, but difficult and clunkly for command-line apps to use these services.

With `generic_oauth` you can synchronosly generate access_tokens for any oauth api with just a few lines of code.

Implementations included:

- Google
- Github
- Facebook
- Spotify

## Sample Usage

```
import secrets
import requests
from generic_oauth import SpotifyOAuth

# Get a spotify access_token in just 2 lines.
o = SpotifyOAuth(secrets.client_id, secrets.client_secret, secrets.redirect_uri, secrets.scope_string)
access_data = o.get_access_code()

headers = {'Authorization': 'Bearer ' + access_data['access_token']}
r = requests.get('https://api.spotify.com/v1/me', headers=headers)
print r.json()

```

## Documentation

`OAuthWebFlowController` is an abstract class responsible for handling the bulk of the oauth 2.0 web flow. To implement a handler for an OAuth api not already included, you will need to make a subclass of this class and override the `authorization_url()` and `parse_temp_code()` methods.

`OAuthWebFlowController` creates a temporarly local HTTP server to accept data sent to the `redirect_uri`. The default `redirect_uri` supported is http://localhost:5555. If you would like to use a different url, you will need to change the `port` param in the `__init__` method. For example if you use http://localhost:4321, you would set port=4321.

## How to include in project

TODO

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

generic_oauth-0.1.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file generic_oauth-0.1.tar.gz.

File metadata

  • Download URL: generic_oauth-0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for generic_oauth-0.1.tar.gz
Algorithm Hash digest
SHA256 225ef5553708bbf5e1f8762173df408f46a0209f780c748ed2af554538a7193f
MD5 b6cecdc807fa20a9e49f1555b44c6c43
BLAKE2b-256 d126dd0dfd01825bc5a2490042cdde3a7e3ccfbbd98afbeaa24edff1f1341f05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page