This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

Flask-GSA

A Flask extension for interacting with Google OAuth2 Service Accounts.

Getting Started

Requirements

  • Python 2.6+
  • OpenSSL

Installation

Flask-GSA can be installed with pip:

$ pip install Flask-GSA

Basic Usage

A minimal sample application:

from flask import Flask
from flask_gsa import GoogleServiceAccount

app = Flask(__name__)

# Create a service account object and assign a config variable prefix
analytics_gsa = GoogleServiceAccount('ANALYTICS_GSA')

# Set up the service account settings
app.config['ANALYTICS_GSA_PK_FILE'] = 'analytics.p12'
app.config['ANALYTICS_GSA_PK_PASSWORD'] = 'notasecret'
app.config['ANALYTICS_GSA_EMAIL'] = '12345abcd@developer.gserviceaccount.com'

# Initialize the extension
analytics_gsa.init_app(app)

@app.route('/token')
def get_analytics_token():
    scopes = [
        'https://www.googleapis.com/auth/analytics.readonly'
    ]
    return analytics_gsa.generate_token(scopes)

if __name__ == '__main__':
    app.run(port=5000, debug=True)

Run the app:

$ python example.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat

Get a token:

$ http :5000/token
{
    "expires": 1437698007,
    "issued": 1437694408,
    "token": "ya29.uQEiLFkED9YMTG7CvctLYtJqnOny_8CkA4_Hxk5yxzEhXR3eNSO-Pca20BRNxBT74XYD",
    "token_type": "Bearer"
}

Configuration Options:

When creating an instance of the extension, you must choose a config variable
prefix. This allows multiple service account objects to be used with the same
app:
analytics_gsa = GoogleServiceAccount('ANALYTICS')
gdrive_gsa = GoogleServiceAccount('GDRIVE')

The following config variables are required:

Config Variable Description
<prefix>_PK_FILE Path to the PKCS12 key that will be used to sign tokens
<prefix>_PK_PASSWORD Password for the PKCS12 private key
<prefix>_EMAIL Service Account’s email address

# Revision History

## 0.1.1 (2015/07/23)

  • Fix tests

## 0.1.0 (2015/07/23)

  • Initial release
Release History

Release History

0.1.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Flask_GSA-0.1.1-py2-none-any.whl (4.8 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Jul 24, 2015
Flask-GSA-0.1.1.tar.gz (4.5 kB) Copy SHA256 Checksum SHA256 Source Jul 24, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting