Пример #1
0
def callback(request):
    code = request.GET.get('code')
    access_token = Singly.get_access_token(code)
    if access_token is None:
        raise Exception('access_token missing in callback response!')
    request.session['access_token'] = access_token
    return redirect('/')
Пример #2
0
def home(request):
    if request.session.get('access_token') is None:
        return redirect('/login')
    data = Singly.request(request.session['access_token'], '/profiles')
    profiles = json.loads(data)
    page = \
    <ui:page>
        <h1>Singly Sandbox</h1>
        <h2>Authenticate with the following services:</h2>
        <ui:services services={SERVICES} profiles={profiles} />
Пример #3
0
def auth(request, service):
    if service not in SERVICES:
        return redirect('/')
    return redirect(Singly.get_auth_url(service))