Python flask.current_app.route() Examples
The following are 4
code examples of flask.current_app.route().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask.current_app
, or try the search function
.
Example #1
Source File: google.py From PowerDNS-Admin with MIT License | 5 votes |
def google_oauth(): if not Setting().get('google_oauth_enabled'): return None def fetch_google_token(): return session.get('google_token') def update_token(token): session['google_token'] = token return token google = authlib_oauth_client.register( 'google', client_id=Setting().get('google_oauth_client_id'), client_secret=Setting().get('google_oauth_client_secret'), api_base_url=Setting().get('google_base_url'), request_token_url=None, access_token_url=Setting().get('google_token_url'), authorize_url=Setting().get('google_authorize_url'), client_kwargs={'scope': Setting().get('google_oauth_scope')}, fetch_token=fetch_google_token, update_token=update_token) @current_app.route('/google/authorized') def google_authorized(): session['google_oauthredir'] = url_for( '.google_authorized', _external=True) token = google.authorize_access_token() if token is None: return 'Access denied: reason=%s error=%s' % ( request.args['error_reason'], request.args['error_description'] ) session['google_token'] = (token) return redirect(url_for('index.login')) return google
Example #2
Source File: github.py From PowerDNS-Admin with MIT License | 5 votes |
def github_oauth(): if not Setting().get('github_oauth_enabled'): return None def fetch_github_token(): return session.get('github_token') def update_token(token): session['github_token'] = token return token github = authlib_oauth_client.register( 'github', client_id=Setting().get('github_oauth_key'), client_secret=Setting().get('github_oauth_secret'), request_token_params={'scope': Setting().get('github_oauth_scope')}, api_base_url=Setting().get('github_oauth_api_url'), request_token_url=None, access_token_url=Setting().get('github_oauth_token_url'), authorize_url=Setting().get('github_oauth_authorize_url'), client_kwargs={'scope': Setting().get('github_oauth_scope')}, fetch_token=fetch_github_token, update_token=update_token) @current_app.route('/github/authorized') def github_authorized(): session['github_oauthredir'] = url_for('.github_authorized', _external=True) token = github.authorize_access_token() if token is None: return 'Access denied: reason=%s error=%s' % ( request.args['error'], request.args['error_description']) session['github_token'] = (token) return redirect(url_for('index.login')) return github
Example #3
Source File: azure.py From PowerDNS-Admin with MIT License | 5 votes |
def azure_oauth(): if not Setting().get('azure_oauth_enabled'): return None def fetch_azure_token(): return session.get('azure_token') def update_token(token): session['azure_token'] = token return token azure = authlib_oauth_client.register( 'azure', client_id=Setting().get('azure_oauth_key'), client_secret=Setting().get('azure_oauth_secret'), api_base_url=Setting().get('azure_oauth_api_url'), request_token_url=None, access_token_url=Setting().get('azure_oauth_token_url'), authorize_url=Setting().get('azure_oauth_authorize_url'), client_kwargs={'scope': Setting().get('azure_oauth_scope')}, fetch_token=fetch_azure_token, ) @current_app.route('/azure/authorized') def azure_authorized(): session['azure_oauthredir'] = url_for('.azure_authorized', _external=True, _scheme='https') token = azure.authorize_access_token() if token is None: return 'Access denied: reason=%s error=%s' % ( request.args['error'], request.args['error_description']) session['azure_token'] = (token) return redirect(url_for('index.login', _external=True, _scheme='https')) return azure
Example #4
Source File: oidc.py From PowerDNS-Admin with MIT License | 5 votes |
def oidc_oauth(): if not Setting().get('oidc_oauth_enabled'): return None def fetch_oidc_token(): return session.get('oidc_token') def update_token(token): session['oidc_token'] = token return token oidc = authlib_oauth_client.register( 'oidc', client_id=Setting().get('oidc_oauth_key'), client_secret=Setting().get('oidc_oauth_secret'), api_base_url=Setting().get('oidc_oauth_api_url'), request_token_url=None, access_token_url=Setting().get('oidc_oauth_token_url'), authorize_url=Setting().get('oidc_oauth_authorize_url'), client_kwargs={'scope': Setting().get('oidc_oauth_scope')}, fetch_token=fetch_oidc_token, update_token=update_token) @current_app.route('/oidc/authorized') def oidc_authorized(): session['oidc_oauthredir'] = url_for('.oidc_authorized', _external=True) token = oidc.authorize_access_token() if token is None: return 'Access denied: reason=%s error=%s' % ( request.args['error'], request.args['error_description']) session['oidc_token'] = (token) return redirect(url_for('index.login')) return oidc