コード例 #1
0
ファイル: admin_views.py プロジェクト: dcifuen/gentlemeet
 def start_oauth2_dance(self):
     login_hint = ''
     scope = ''
     client = Client.get_by_id(1)
     if not client:
         # If client does not exist then create an empty one
         client = Client(id=1)
         client.installer_user = users.get_current_user().email()
         client.put()
     # Get the login hint from configuration
     approval_prompt = 'auto' if client.refresh_token else 'force'
     scope = constants.OAUTH2_SCOPE
     redirect_uri = helpers.url_for('oauth.oauth_callback',
                                    _external=True)
     oauth_helper = OAuthDanceHelper(redirect_uri, approval_prompt, scope)
     url = oauth_helper.step1_get_authorize_url()
     #TODO: Add a random token to avoid forgery
     return redirect(url)
コード例 #2
0
def start_oauth2_dance():
    login_hint = ""
    scope = ""
    client = Client.get_by_id(1)
    if not client:
        # If client does not exist then create an empty one
        client = Client(id=1)
        client.put()
    # Get the login hint from configuration

    # approval_prompt = 'auto' if client.reseller_refresh_token else 'force'
    # Always force to be sure to get valid refresh token
    approval_prompt = "force"
    login_hint = get_setting("OAUTH2_RESELLER_DOMAIN_USER")
    scope = get_setting("OAUTH2_SCOPE")
    redirect_uri = helpers.url_for("oauth_callback", _external=True)
    oauth_helper = OAuthDanceHelper(scope=scope, redirect_uri=redirect_uri, approval_prompt=approval_prompt)
    url = oauth_helper.step1_get_authorize_url()
    # TODO: Add a random token to avoid forgery
    return redirect("%s&login_hint=%s" % (url, login_hint))
コード例 #3
0
ファイル: views.py プロジェクト: Eforcers/inbox-cleaner
def start_oauth2_dance(domain):
    current_user = users.get_current_user()
    user_email = current_user.email()
    login_hint = user_email
    user_domain = current_user.email().split('@')[1]

    if user_domain != domain:
        domain = user_domain

    primary_domain = PrimaryDomain.get_or_create(domain)
    approval_prompt = 'auto' if primary_domain.refresh_token else 'force'
    scope = constants.OAUTH2_SCOPES
    state = urllib.quote(domain)

    redirect_uri = url_for('oauth_callback', _external=True)
    oauth_helper = OAuthDanceHelper(scope=scope, redirect_uri=redirect_uri,
                                    approval_prompt=approval_prompt)
    url = oauth_helper.step1_get_authorize_url()
    # TODO: Add a random token to avoid forgery
    return redirect("%s&state=%s&login_hint=%s" % (url, state, login_hint))