def authorize_gcal(request): client = oauth.get_client_by_name(oauth_impl.OAUTH_CLIENT_NAME) authorize_url = client.get_authorize_url(access_type='offline', approval_prompt='force') client.set_state(request) context = {'authorize_url': authorize_url} return render(request, 'gcal_sync/authorize_gcal.html', context)
def login(request): if request.user.is_authenticated(): return redirect('web_index') client = oauth.get_client_by_name('todoist') authorize_url = client.get_authorize_url() client.set_state(request) return render(request, 'login.html', {'authorize_url': authorize_url})
def get_authorized_client(user): """ Return the Authorized requests session object """ client = oauth.get_client_by_name(oauth_impl.OAUTH_CLIENT_NAME) return client.get_oauth2_session(user)