Giter Site home page Giter Site logo

flask-github's Introduction

flask-github

Flask-github is an extension for authenticating Flask applications with Github. It also provides support for various other requests to the Github API.

Installation

pip install flask-github

Usage

An example application is provided. Getting it up and running should be pretty straightforward:

  1. Create a new application on Github (or use an existing one)

  2. Add the client_id and client_secret to config.json

  3. Start the server:

     python example/example.py
    

Example App URLs

Redirect the user to authenticate with Github:

http://localhost:5000/login

Check if the user is a member of an organization:

http://localhost:5000/orgs/<organization_name>

Check if the user belongs to a certain team:

http://localhost:5000/teams/<team_id>

API Requests

After authenticating, this extension also provides methods for doing GET requests to the Github API as the authenticated user.

github = GithubAuth(
	client_id='123456789',
	client_secret='987654321',
	session_key='user_id'
)

# returns the authenticated user
github.get_github_user()

# returns true if the authenticated user is a member of the organization
github.has_org_access('mindsnacks')

Options

  • session_key -- Key for the value stored in the session to determine if a user is logged in
  • client_id -- Given by Github when creating an application
  • client_secret -- Given by Github when creating an application

flask-github's People

Contributors

cenkalti avatar jarodl avatar spulec avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.