def make_client_from_auth_session(auth): c = Client( auth_endpoint = auth.auth_endpoint, token_endpoint= auth.token_endpoint, resource_endpoint =auth.resource_endpoint, client_id = auth.client_id, client_secret = auth.client_secret, redirect_uri = auth.redirect_uri) return c
def get_oauth2_starter_url(provider_name, csrf_token): """returns redirect url for the oauth2 protocol for a given provider""" from sanction.client import Client providers = get_enabled_login_providers() params = providers[provider_name] client_id = getattr(askbot_settings, provider_name.upper() + '_KEY') redirect_uri = site_url(reverse('user_complete_oauth2_signin')) client = Client(auth_endpoint=params['auth_endpoint'], client_id=client_id, redirect_uri=redirect_uri) return client.auth_uri(state=csrf_token)
def shoe(): if 'shoe_client' in session: c = session['shoe_client'] else: c = Client( auth_endpoint=AUTH_URL, token_endpoint=TOKEN_URL, resource_endpoint=API_BASE, redirect_uri=REDIRECT_URL, client_id=CLIENT_ID, client_secret=CLIENT_KEY ) if hasattr(c, 'refresh_token'): c.request_token(grant_type="refresh_token", refresh_token=c.refresh_token) # XXX: Refactor this to be only when we're expired or something. session['shoe_client'] = c return c