realms-wiki/realms/modules/auth/oauth/models.py

33 lines
913 B
Python
Raw Normal View History

2015-10-14 06:52:30 +03:00
from flask import render_template
from flask_oauthlib.client import OAuth
from realms import config
from ..models import BaseUser
oauth = OAuth()
2015-10-15 07:08:56 +03:00
users = {}
2015-10-14 06:52:30 +03:00
2015-10-15 07:08:56 +03:00
providers = {
'twitter': {
'oauth': dict(
2015-10-15 01:36:22 +03:00
base_url='https://api.twitter.com/1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_url='https://api.twitter.com/oauth/access_token',
2015-10-15 07:08:56 +03:00
authorize_url='https://api.twitter.com/oauth/authenticate')
}
}
2015-10-15 01:36:22 +03:00
2015-10-15 07:08:56 +03:00
class User(BaseUser):
@classmethod
def get_app(cls, provider):
return oauth.remote_app(provider,
consumer_key=config.OAUTH.get(provider, {}).get('key'),
consumer_secret=config.OAUTH.get(provider, {}).get('secret'),
**providers[provider]['oauth'])
2015-10-14 06:52:30 +03:00
@staticmethod
def login_form():
2015-10-15 07:08:56 +03:00
pass