Exemplo n.º 1
0
def yahoo_authorized(resp):
  if resp is None:
    flask.flash(u'You denied the request to sign in.')
    return flask.redirect(util.get_next_url())

  flask.session['oauth_token'] = (
      resp['oauth_token'],
      resp['oauth_token_secret'],
    )

  try:
    yahoo_guid = yahoo.get(
        '/v1/me/guid', data={'format': 'json', 'realm': 'yahooapis.com'}
      ).data['guid']['value']

    profile = yahoo.get(
        '/v1/user/%s/profile' % yahoo_guid,
        data={'format': 'json', 'realm': 'yahooapis.com'}
      ).data['profile']
  except:
    flask.flash(
        'Something went wrong with Yahoo! sign in. Please try again.',
        category='danger',
      )
    return flask.redirect(util.get_next_url())
  user_db = retrieve_user_from_yahoo(profile)
  return signin_user_db(user_db)
Exemplo n.º 2
0
    def parse_urls(self, response):
        location = response.css('[data-test="store-button"] ::text').get()
        self.driver = response.request.meta['driver']
        location = self.driver.find_element_by_css_selector(
            '[data-test="store-button"]').text
        print(f"detected location - {location}")
        if location != self.location:
            self.change_store_location(response)

        self.section_group = response.css(".subcategory.category")
        section_group = response.css(".subcategory.category")
        for section in section_group:
            section_name = section.css(".css-1pita2n ::text").get()
            url_nodes = section.css("ul.children a")
            for url_node in url_nodes:
                subsection_name = url_node.css("::text").get()
                url = self.base_url + url_node.css("::attr(href)").get()

                store_url(self.conn, url, self.store_id,
                          lookup_category("", section_name, subsection_name),
                          section_name, subsection_name)

        finish_url(self.conn, self.store_id, response.url)
        function = self.parse
        item_to_find = '[add-to-cart]'
        if len(self.start_urls) != 0:
            next_url = self.start_urls.pop()
            store_url(self.conn, next_url, self.store_id, "", "", "")
            function = self.parse_urls
            item_to_find = '[data-test="store-button"]'
            #request = self.create_parse_request(next_url,self.parse_urls,EC.element_to_be_clickable((By.CSS_SELECTOR, '[data-test="store-button"]')))

        else:
            next_url = get_next_url(self.cursor, 1)
        #    request = self.create_parse_request(next_url,self.parse,EC.element_to_be_clickable((By.CSS_SELECTOR, '[add-to-cart]')))

        if next_url is None:
            print("No more URLs to parse. Finishing")
            return
        else:
            request = self.create_parse_request(
                next_url, function,
                EC.element_to_be_clickable((By.CSS_SELECTOR, item_to_find)))

        #FIXME these try except blocks don't actually handle timeout exceptions from navigating to the wrong url
        try:
            yield request
        except:
            print(f"Parse -  Errored out processing request for - {next_url} ")
            next_url = get_next_url(self.cursor, 2)
            print(f"Parse - Now handling {next_url}")
            request = self.create_parse_request(
                next_url, self.parse,
                EC.element_to_be_clickable((By.CSS_SELECTOR, '[add-to-cart]')))
            yield request
Exemplo n.º 3
0
def signin_twitter():
    flask.session.pop('oauth_token', None)
    try:
        return twitter.authorize(callback=flask.url_for(
            'twitter_oauth_authorized', next=util.get_next_url()), )
    except:
        flask.flash(
            'Something went terribly wrong with Twitter sign in. Please try again.',
            category='danger',
        )
        return flask.redirect(flask.url_for('signin',
                                            next=util.get_next_url()))
Exemplo n.º 4
0
def linkedin_authorized():
  err = flask.request.args.get('error')
  if err in ['user_cancelled_login', 'user_cancelled_authorize']:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())
  id_token = linkedin.authorize_access_token()
  if id_token is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())
  me = linkedin.get('me?projection=(id,firstName,lastName)')
  user_db = retrieve_user_from_linkedin(me.json())
  return auth.signin_user_db(user_db)
Exemplo n.º 5
0
def signin_twitter():
  flask.session.pop('oauth_token', None)
  try:
    return twitter.authorize(
        callback=flask.url_for('twitter_authorized', next=util.get_next_url()),
      )
  except:
    flask.flash(
        'Something went terribly wrong with Twitter sign in. Please try again.',
        category='danger',
      )
    return flask.redirect(flask.url_for('signin', next=util.get_next_url()))
Exemplo n.º 6
0
def bitbucket_authorized():
    err = flask.request.args.get('error')
    if err in ['access_denied']:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())
    id_token = bitbucket.authorize_access_token()
    if id_token is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())
    me = bitbucket.get('user')
    user_db = retrieve_user_from_bitbucket(me.json())
    return auth.signin_user_db(user_db)
Exemplo n.º 7
0
def signin_user_db(user_db):
    if not user_db:
        return flask.redirect(flask.url_for('welcome'))
    flask_user_db = FlaskUser(user_db)
    if login.login_user(flask_user_db):
        user_db.put_async()
        flask.flash('Hello %s, welcome to %s!!!' % (
            user_db.name, config.CONFIG_DB.brand_name,
        ), category='success')
        return flask.redirect(util.get_next_url())
    else:
        flask.flash('Sorry, but you could not sign in.', category='danger')
        return flask.redirect(flask.url_for('welcome'))


#def get_or_create_google_plus_user(google_id, access_token, expires_at, refresh_token, **params):
#    user = model.User.retrieve_one_by('username', google_id['name'])
#    if user is None:
#        user = current_user_db()
#        user.google_display_name = google_id['name']
#        user.google_plus_id = google_id['id']
#        if google_id.has_key('picture'):
#            user.google_public_profile_url = google_id['picture']
#        user.access_token = access_token
#        user.expires_at = expires_at
#        user.refresh_token = refresh_token
#
#    user.put()
#    return user
Exemplo n.º 8
0
def signin():
    next_url = util.get_next_url()
    form = None
    if config.CONFIG_DB.has_email_authentication:
        form = form_with_recaptcha(SignInForm())
        save_request_params()
        if form.validate_on_submit():
            result = get_user_db_from_email(form.email.data,
                                            form.password.data)
            if result:
                cache.reset_auth_attempt()
                return signin_user_db(result)
            if result is None:
                form.email.errors.append('Email or Password do not match')
            if result is False:
                return flask.redirect(flask.url_for('welcome'))
        if not form.errors:
            form.next_url.data = next_url

    if form and form.errors:
        cache.bump_auth_attempt()

    return flask.render_template(
        'auth/auth.html',
        title='Sign in',
        html_class='auth',
        next_url=next_url,
        form=form,
        form_type='signin'
        if config.CONFIG_DB.has_email_authentication else '',
        **urls_for_oauth(next_url))
Exemplo n.º 9
0
def odnoklassniki_authorized(resp):
  if resp is None:
    return 'Access denied: reason=%s error=%s' % (
      flask.request.args['error_reason'],
      flask.request.args['error_description']
    )
  access_token = resp['access_token']
  flask.session['oauth_token'] = (access_token, '')
  try:
      data={
      'method':'users.getCurrentUser',
      'application_key':odnoklassniki.consumer_public,
      'access_token':access_token,
      }
      data['sig']=odnoklassniki_oauth_sig(data, client_secret=odnoklassniki.consumer_secret)
      params = urlencode(data)
      url = odnoklassniki.base_url + 'fb.do'
      request = Request(url, params)
      odnoklassniki_resp = json.loads(urlopen(request).read())
      user_db = retrieve_user_from_odnoklassniki(odnoklassniki_resp)
  except:
      flask.flash(
        u'Упс, что-то пошло не так, попробуйте зайти позже.',
        category='danger'
      )
      return flask.redirect(flask.url_for('auth.login', next=util.get_next_url()))
  return login_user_db(user_db)
Exemplo n.º 10
0
def login():
  next_url = util.get_next_url()
  if flask.url_for('auth.login') in next_url:
    next_url = flask.url_for('pages.index')

  google_login_url = flask.url_for('auth.login_google', next=next_url)
  twitter_login_url = flask.url_for('auth.login_twitter', next=next_url)
  facebook_login_url = flask.url_for('auth.login_facebook', next=next_url)
  vk_login_url = flask.url_for('auth.login_vk', next=next_url)
  yandex_login_url = flask.url_for('auth.login_yandex', next=next_url)
  mailru_login_url = flask.url_for('auth.login_mailru', next=next_url)
  odnoklassniki_login_url = flask.url_for('auth.login_odnoklassniki', next=next_url)

  return flask.render_template(
      'auth/login.html',
      title='Login',
      html_class='login',
      google_login_url=google_login_url,
      twitter_login_url=twitter_login_url,
      facebook_login_url=facebook_login_url,
      vk_login_url=vk_login_url,
      yandex_login_url=yandex_login_url,
      mailru_login_url=mailru_login_url,
      odnoklassniki_login_url=odnoklassniki_login_url,
      next_url=next_url,
    )
Exemplo n.º 11
0
def mailru_authorized(resp):
  if resp is None:
    return 'Access denied: reason=%s error=%s' % (
      flask.request.args['error_reason'],
      flask.request.args['error_description']
    )
  access_token = resp['access_token']
  flask.session['oauth_token'] = (access_token, '')
  try:
    data={
    'method':'users.getInfo',
    'app_id':mailru.consumer_key,
    'session_key':access_token,
    'secure':'1'
    }
    data['sig']=mailru_sig(data)
    params = urlencode(data)
    url = mailru.base_url + 'platform/api'
    request = Request(url, params)
    mailru_resp = json.loads(urlopen(request).read())
    user_db = retrieve_user_from_mailru(mailru_resp[0])
  except:
    flask.flash(
      u'Упс, что-то пошло не так, попробуйте зайти позже.',
      category='danger'
    )
    return flask.redirect(flask.url_for('auth.login', next=util.get_next_url()))
  return login_user_db(user_db)
Exemplo n.º 12
0
 def start_requests(self):
     self.logger.info("lua script - " + self.expand_and_scroll_lua)
     next_url = get_next_url(self.cursor, 1, store_id=self.store_id)
     current_url = next_url
     yield SplashRequest(current_url,
                         self.parse,
                         args={'lua_source': self.expand_and_scroll_lua})
Exemplo n.º 13
0
    def scrape_urls(self, response):
        #1. sort through data and extract urls
        #2. put urls together
        #3. Loop to each url, returning @parse
        base_url = "https://www.walmart.com"
        self.raw = response.body_as_unicode()
        #print("raw: " + self.raw)
        remove = ['{', '}', 'Link', ' ']
        self.cleaned = self.raw
        for char in remove:
            self.cleaned = self.cleaned.replace(char, '')
        self.comma_split = self.cleaned.split('","')
        #print ("cleaned - " + cleaned)
        #print ("comma_split - " )
        #print (*comma_split)
        self.colon_split = [entry.split('":"') for entry in self.comma_split]
        #inspect_response(response, self)
        self.colon_split[0].remove('"sections')
        #print ("colon_split - ")
        #print (*colon_split)
        self.urls = [entry[-1] for entry in self.colon_split]
        #print("urls - ")
        #print(self.urls)

        section = "unset"
        subsection = "unset"

        self.section_dict = {}
        chars_to_remove=["\'","&"]
        for entry in self.colon_split:

            # each entry will have a subheading (normally at 0 unless it has a heading entry)
            section = clean_string(entry[0],chars_to_remove)
            url_end = clean_string(entry[-1],"\"")

            # if its a section header it will contain 3 entries
            #   and all subsequent entries will have the same heading
            if len(entry) > 2:
                section = clean_string(entry[0],chars_to_remove)
                subsection = clean_string(entry[1],chars_to_remove)

            url = base_url + url_end
            category=lookup_category("",section,subsection)
            store_url(self.conn,url,self.store_id,category,section,subsection)
            #self.section_dict[url] = (self.section, self.subsection)

            #print(section, subsection, url)

        next_url=get_next_url(self.cursor, 1)
        if next_url is None:
            print("No more urls to parse finishing")
        else:
            yield SplashRequest(url,
                            self.parse,
                            endpoint='render.html',
                            args={
                                'wait': 10,
                                'section': section,
                                'subsection': subsection
                            })
Exemplo n.º 14
0
    def run(self, response):
        page_1_str = self.page_str + "1"
        meta_url = response.meta.get("url")
        #Basically the website redirects us to the url and page_1_str, which isn't added to our database
        # So we trim that off so we can get the url in our database
        this_url = trim_url(response.url, page_1_str)
        self.logger.info(f"inside run for {this_url}, meta_url: {meta_url}")
        if meta_url != this_url:
            self.logger.info(
                f"meta_url: {meta_url} !=  response.url: {response.url}, therefore it must be invalid - skipping"
            )
            this_url = meta_url
        else:
            self.scrape_urls(response)

        finish_url(self.conn, self.store_id, this_url, scrape_urls=True)
        self.logger.info("finishing url - " + this_url)
        next_url = get_next_url(self.cursor, 1, self.store_id, True)
        if next_url is None:
            self.logger.info(
                "Next url is none therefore we must be finished ! ")
            return
        else:
            next_request = create_unfiltered_parse_request(
                next_url, self.run,
                EC.element_to_be_clickable(
                    (By.CSS_SELECTOR, '#openFulfillmentModalButton')))
        self.logger.info(f"got next_url - {next_url}")

        yield next_request
Exemplo n.º 15
0
def signup():
    next_url = util.get_next_url()
    form = None
    if config.CONFIG_DB.has_email_authentication:
        form = form_with_recaptcha(SignUpForm())
        save_request_params()
        if form.validate_on_submit():
            user_db = model.User.get_by('email', form.email.data)
            if user_db:
                form.email.errors.append('This email is already taken.')

            if not form.errors:
                user_db = create_user_db(
                    None,
                    util.create_name_from_email(form.email.data),
                    form.email.data,
                    form.email.data,
                )
                user_db.put()
                task.activate_user_notification(user_db)
                cache.bump_auth_attempt()
                return flask.redirect(flask.url_for('welcome'))

    if form and form.errors:
        cache.bump_auth_attempt()

    title = 'Sign up' if config.CONFIG_DB.has_email_authentication else 'Sign in'
    return flask.render_template('auth/auth.html',
                                 title=title,
                                 html_class='auth',
                                 next_url=next_url,
                                 form=form,
                                 **urls_for_oauth(next_url))
Exemplo n.º 16
0
def signin_github():
  return github.authorize(
    callback=flask.url_for('github_authorized',
      next=util.get_next_url(),
      _external=True
    )
  )
Exemplo n.º 17
0
def signin_github():
  return github.authorize(
      callback=flask.url_for('github_authorized',
          next=util.get_next_url(),
          _external=True,
        )
    )
Exemplo n.º 18
0
def signin():
  next_url = util.get_next_url()
  form = None
  if config.CONFIG_DB.has_email_authentication:
    form = form_with_recaptcha(SignInForm())
    save_request_params()
    if form.validate_on_submit():
      result = get_user_db_from_email(form.email.data, form.password.data)
      if result:
        cache.reset_auth_attempt()
        return signin_user_db(result)
      if result is None:
        form.email.errors.append('Email or Password do not match')
      if result is False:
        return flask.redirect(flask.url_for('welcome'))
    if not form.errors:
      form.next_url.data = next_url

  if form and form.errors:
    cache.bump_auth_attempt()

  return flask.render_template(
    'auth/auth.html',
    title='Sign in',
    html_class='auth',
    next_url=next_url,
    form=form,
    form_type='signin' if config.CONFIG_DB.has_email_authentication else '',
    **urls_for_oauth(next_url)
  )
Exemplo n.º 19
0
def signup():
  next_url = util.get_next_url()
  form = None
  if config.CONFIG_DB.has_email_authentication:
    form = form_with_recaptcha(SignUpForm())
    save_request_params()
    if form.validate_on_submit():
      user_db = model.User.get_by('email', form.email.data)
      if user_db:
        form.email.errors.append('This email is already taken.')

      if not form.errors:
        user_db = create_user_db(
          None,
          util.create_name_from_email(form.email.data),
          form.email.data,
          form.email.data,
        )
        user_db.put()
        task.activate_user_notification(user_db)
        cache.bump_auth_attempt()
        return flask.redirect(flask.url_for('welcome'))

  if form and form.errors:
    cache.bump_auth_attempt()

  title = 'Sign up' if config.CONFIG_DB.has_email_authentication else 'Sign in'
  return flask.render_template(
    'auth/auth.html',
    title=title,
    html_class='auth',
    next_url=next_url,
    form=form,
    **urls_for_oauth(next_url)
  )
Exemplo n.º 20
0
def signin():
  next_url = util.get_next_url()
  if flask.url_for('signin') in next_url:
    next_url = flask.url_for('welcome')

  bitbucket_signin_url = flask.url_for('signin_bitbucket', next=next_url)
  dropbox_signin_url = flask.url_for('signin_dropbox', next=next_url)
  facebook_signin_url = flask.url_for('signin_facebook', next=next_url)
  github_signin_url = flask.url_for('signin_github', next=next_url)
  google_signin_url = flask.url_for('signin_google', next=next_url)
  linkedin_signin_url = flask.url_for('signin_linkedin', next=next_url)
  twitter_signin_url = flask.url_for('signin_twitter', next=next_url)
  vk_signin_url = flask.url_for('signin_vk', next=next_url)
  windowslive_signin_url = flask.url_for('signin_windowslive', next=next_url)

  return flask.render_template(
      'signin.html',
      title='Please sign in',
      html_class='signin',
      bitbucket_signin_url=bitbucket_signin_url,
      dropbox_signin_url=dropbox_signin_url,
      facebook_signin_url=facebook_signin_url,
      github_signin_url=github_signin_url,
      google_signin_url=google_signin_url,
      linkedin_signin_url=linkedin_signin_url,
      twitter_signin_url=twitter_signin_url,
      vk_signin_url=vk_signin_url,
      windowslive_signin_url=windowslive_signin_url,
      next_url=next_url,
    )
Exemplo n.º 21
0
def login():
    next_url = util.get_next_url()
    if flask.url_for("auth.login") in next_url:
        next_url = flask.url_for("pages.index")

    google_login_url = flask.url_for("auth.login_google", next=next_url)
    twitter_login_url = flask.url_for("auth.login_twitter", next=next_url)
    facebook_login_url = flask.url_for("auth.login_facebook", next=next_url)
    vk_login_url = flask.url_for("auth.login_vk", next=next_url)
    yandex_login_url = flask.url_for("auth.login_yandex", next=next_url)
    mailru_login_url = flask.url_for("auth.login_mailru", next=next_url)
    odnoklassniki_login_url = flask.url_for("auth.login_odnoklassniki", next=next_url)

    return flask.render_template(
        "auth/login.html",
        title="Login",
        html_class="login",
        google_login_url=google_login_url,
        twitter_login_url=twitter_login_url,
        facebook_login_url=facebook_login_url,
        vk_login_url=vk_login_url,
        yandex_login_url=yandex_login_url,
        mailru_login_url=mailru_login_url,
        odnoklassniki_login_url=odnoklassniki_login_url,
        next_url=next_url,
    )
Exemplo n.º 22
0
    def start_requests(self):
        url = self.start_urls[0]
        request = create_unfiltered_parse_request(url,
                                                  self.collect_menu,
                                                  EC.element_to_be_clickable(
                                                      (By.CSS_SELECTOR, '[id="catalog-nav-main-shop.categories"]')),
                                                  meta_url=url
                                                  )

        if is_url_scraped(self.cursor, url, self.store_id, scrape_urls=True):
            #next_url = get_next_url(self.cursor, 1, store_id=self.store_id,
            #                        scrape_urls=True,filter=self.page_string,reverse_filter=True)
            next_url = get_next_url(self.cursor, 1, store_id=self.store_id,
                        scrape_urls=True)

            request = create_unfiltered_parse_request(next_url,
                                           self.handle_first_request,
                                           EC.element_to_be_clickable(
                                               (By.CSS_SELECTOR, '#shopping-selector-parent-process-modal-close-click')),
                                           meta_url=next_url,
                                           errback=self.handle_pagination
                                           )

        store_url(self.conn, url, self.store_id, "Start", "", "")
        yield request
Exemplo n.º 23
0
def login_twitter():
    flask.session.pop("oauth_token", None)
    try:
        return twitter.authorize(callback=flask.url_for("auth.twitter_oauth_authorized", next=util.get_next_url()))
    except:
        flask.flash("Something went terribly wrong with Twitter login. Please try again.", category="danger")
        return flask.redirect(flask.url_for("auth.login", next=util.get_next_url()))
Exemplo n.º 24
0
def microsoft_authorized():
    id_token = microsoft.authorize_access_token()
    if id_token is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())
    me = microsoft.get('me')
    user_db = retrieve_user_from_microsoft(me.json())
    return auth.signin_user_db(user_db)
Exemplo n.º 25
0
def signin_windowslive():
  return windowslive.authorize(
      callback=flask.url_for(
          'windowslive_authorized',
          next=util.get_next_url(),
          _external=True,
        )
    )
Exemplo n.º 26
0
def github_authorized():
    id_token = github.authorize_access_token()
    if id_token is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())
    me = github.get('user')
    user_db = retrieve_user_from_github(me.json())
    return auth.signin_user_db(user_db)
Exemplo n.º 27
0
def login_yandex():
  params = dict(yandex.request_token_params)
  params['client_id'] = yandex.consumer_key
  params['response_type'] = 'code'
  params['state'] = util.get_next_url()
  flask.session[yandex.name + '_oauthredir'] = flask.url_for('auth.yandex_authorized')
  url = add_query(yandex.expand_url(yandex.authorize_url), params)
  return flask.redirect(url)
Exemplo n.º 28
0
def twitter_oauth_authorized(resp):
    if resp is None:
        flask.flash(u"You denied the request to sign in.")
        return flask.redirect(util.get_next_url())

    flask.session["oauth_token"] = (resp["oauth_token"], resp["oauth_token_secret"])
    user_db = retrieve_user_from_twitter(resp)
    return login_user_db(user_db)
Exemplo n.º 29
0
def google_authorized():
    google_user = users.get_current_user()
    if google_user is None:
        flask.flash(u"You denied the request to sign in.")
        return flask.redirect(util.get_next_url())

    user_db = retrieve_user_from_google(google_user)
    return login_user_db(user_db)
Exemplo n.º 30
0
def login_yandex():
    params = dict(yandex.request_token_params)
    params["client_id"] = yandex.consumer_key
    params["response_type"] = "code"
    params["state"] = util.get_next_url()
    flask.session[yandex.name + "_oauthredir"] = flask.url_for("auth.yandex_authorized")
    url = add_query(yandex.expand_url(yandex.authorize_url), params)
    return flask.redirect(url)
Exemplo n.º 31
0
def signin_twitter():
    flask.session.pop("oauth_token", None)
    save_request_params()
    try:
        return twitter.authorize(callback=flask.url_for("twitter_authorized"))
    except:
        flask.flash("Something went wrong with Twitter sign in. Please try again.", category="danger")
        return flask.redirect(flask.url_for("signin", next=util.get_next_url()))
Exemplo n.º 32
0
def signin_bitbucket():
  flask.session['oauth_token'] = None
  return bitbucket.authorize(
      callback=flask.url_for('bitbucket_authorized',
          next=util.get_next_url(),
          _external=True,
        )
    )
Exemplo n.º 33
0
def google_authorized():
  google_user = users.get_current_user()
  if google_user is None:
    flask.flash(u'Вы отвергли запрос на вход.')
    return flask.redirect(util.get_next_url())

  user_db = retrieve_user_from_google(google_user)
  return signin_user_db(user_db)
Exemplo n.º 34
0
def gae_authorized():
  gae_user = users.get_current_user()
  if gae_user is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())

  user_db = retrieve_user_from_gae(gae_user)
  return auth.signin_user_db(user_db)
Exemplo n.º 35
0
def google_authorized():
    google_user = users.get_current_user()
    if google_user is None:
        flask.flash(u'You denied the request to sign in.')
        return flask.redirect(util.get_next_url())

    user_db = retrieve_user_from_google(google_user)
    return signin_user_db(user_db)
Exemplo n.º 36
0
def facebook_authorized(resp):
    if resp is None:
        flask.flash(u"You denied the request to sign in.")
        return flask.redirect(util.get_next_url())

    flask.session["oauth_token"] = (resp["access_token"], "")
    me = facebook.get("/me")
    user_db = retrieve_user_from_facebook(me.data)
    return signin_user_db(user_db)
Exemplo n.º 37
0
def facebook_authorized(resp):
  if resp is None:
    flask.flash(u'Вы отвергли запрос на вход.')
    return flask.redirect(util.get_next_url())

  flask.session['oauth_token'] = (resp['access_token'], '')
  me = facebook.get('/me')
  user_db = retrieve_user_from_facebook(me.data)
  return signin_user_db(user_db)
Exemplo n.º 38
0
def signin_twitter():
  try:
    return auth.signin_oauth(twitter)
  except:
    flask.flash(
        'Something went wrong with Twitter sign in. Please try again.',
        category='danger',
      )
    return flask.redirect(flask.url_for('signin', next=util.get_next_url()))
Exemplo n.º 39
0
def linkedin_authorized():
    id_token = linkedin.authorize_access_token()
    if id_token is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())

    me = linkedin.get('people/~:(id,first-name,last-name,email-address)')
    user_db = retrieve_user_from_linkedin(me.json())
    return auth.signin_user_db(user_db)
Exemplo n.º 40
0
def dropbox_authorized():
  response = dropbox.authorized_response()
  if response is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())
  flask.session['oauth_token'] = (response['access_token'], '')
  me = dropbox.get('account/info')
  user_db = retrieve_user_from_dropbox(me.data)
  return auth.signin_user_db(user_db)
Exemplo n.º 41
0
def twitter_authorized():
    response = twitter.authorized_response()
    if response is None:
        flask.flash("You denied the request to sign in.")
        return flask.redirect(util.get_next_url())

    flask.session["oauth_token"] = (response["oauth_token"], response["oauth_token_secret"])
    user_db = retrieve_user_from_twitter(response)
    return auth.signin_user_db(user_db)
Exemplo n.º 42
0
def dropbox_authorized():
    response = dropbox.authorized_response()
    if response is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())
    flask.session['oauth_token'] = (response['access_token'], '')
    me = dropbox.get('account/info')
    user_db = retrieve_user_from_dropbox(me.data)
    return auth.signin_user_db(user_db)
Exemplo n.º 43
0
def github_authorized():
    response = github.authorized_response()
    if response is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())
    flask.session['oauth_token'] = (response['access_token'], '')
    me = github.get('user')
    user_db = retrieve_user_from_github(me.data)
    return auth.signin_user_db(user_db)
Exemplo n.º 44
0
def signin_vk():
  return vk.authorize(
      callback=flask.url_for(
          'vk_authorized',
          scope='notify',
          next=util.get_next_url(),
          _external=True,
        )
    )
Exemplo n.º 45
0
def github_authorized():
  response = github.authorized_response()
  if response is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())
  flask.session['oauth_token'] = (response['access_token'], '')
  me = github.get('user')
  user_db = retrieve_user_from_github(me.data)
  return auth.signin_user_db(user_db)
Exemplo n.º 46
0
def instagram_authorized():
    response = instagram.authorized_response()
    if response is None:
        flask.flash('You denied the request to sign in.')
        return flask.redirect(util.get_next_url())

    flask.session['oauth_token'] = (response['access_token'], '')
    user_db = retrieve_user_from_instagram(response['user'])
    return auth.signin_user_db(user_db)
Exemplo n.º 47
0
def signin_twitter():
  try:
    return signin_oauth(twitter)
  except:
    flask.flash(
        'Something went wrong with Twitter sign in. Please try again.',
        category='danger',
      )
    return flask.redirect(flask.url_for('signin', next=util.get_next_url()))
Exemplo n.º 48
0
def facebook_authorized(resp):
    if resp is None:
        flask.flash(u'You denied the request to sign in.')
        return flask.redirect(util.get_next_url())

    flask.session['oauth_token'] = (resp['access_token'], '')
    me = facebook.get('/me')
    user_db = retrieve_user_from_facebook(me.data)
    return signin_user_db(user_db)
Exemplo n.º 49
0
def facebook_authorized(resp):
  if resp is None:
    flask.flash(u'You denied the request to sign in.')
    return flask.redirect(util.get_next_url())

  flask.session['oauth_token'] = (resp['access_token'], '')
  me = facebook.get('/me')
  user_db = retrieve_user_from_facebook(me.data)
  return signin_user_db(user_db)
Exemplo n.º 50
0
def instagram_authorized():
  response = instagram.authorized_response()
  if response is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())

  flask.session['oauth_token'] = (response['access_token'], '')
  user_db = retrieve_user_from_instagram(response['user'])
  return auth.signin_user_db(user_db)
Exemplo n.º 51
0
def twitter_oauth_authorized(resp):
    if resp is None:
        flask.flash(u'You denied the request to sign in.')
        return flask.redirect(util.get_next_url())

    flask.session['oauth_token'] = (resp['oauth_token'],
                                    resp['oauth_token_secret'])
    user_db = retrieve_user_from_twitter(resp)
    return signin_user_db(user_db)
Exemplo n.º 52
0
def signin_linkedin():
  flask.session['access_token'] = None
  return linkedin.authorize(
      callback=flask.url_for(
          'linkedin_authorized',
          next=util.get_next_url(),
          _external=True,
        ),
    )
Exemplo n.º 53
0
def instagram_authorized():
    response = instagram.authorized_response()
    if response is None:
        flask.flash("You denied the request to sign in.")
        return flask.redirect(util.get_next_url())

    flask.session["oauth_token"] = (response["access_token"], "")
    user_db = retrieve_user_from_instagram(response["user"])
    return auth.signin_user_db(user_db)
Exemplo n.º 54
0
def facebook_authorized():
  response = facebook.authorized_response()
  if response is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())

  flask.session['oauth_token'] = (response['access_token'], '')
  me = facebook.get('/me?fields=name,email')
  user_db = retrieve_user_from_facebook(me.data)
  return auth.signin_user_db(user_db)
Exemplo n.º 55
0
def linkedin_authorized():
  response = linkedin.authorized_response()
  if response is None:
    flask.flash('You denied the request to sign in.')
    return flask.redirect(util.get_next_url())

  flask.session['access_token'] = (response['access_token'], '')
  me = linkedin.get('people/~:(id,first-name,last-name,email-address)')
  user_db = retrieve_user_from_linkedin(me.data)
  return auth.signin_user_db(user_db)