(hosted_domain=None)
return google_authorization_url
Generate an authorization URL for Google's OAuth2 service.

    Args:
        hosted_domain: Optional GSuite domain to limit access to.

    Returns:
        Authorization URL.
Generate an authorization URL for Google's OAuth2 service.
Generate an authorization URL for Google s OAuth2 service .
def get_oauth2_authorize_url(hosted_domain=None):
    """Generate an authorization URL for Google's OAuth2 service.

    Args:
        hosted_domain: Optional GSuite domain to limit access to.

    Returns:
        Authorization URL.
    """
    auth_uri = current_app.config.get('GOOGLE_OIDC_AUTH_URL', AUTH_URI)
    csrf_token = _generate_random_token()
    nonce = _generate_random_token()
    redirect_uri = url_for(
        'user_views.google_openid_connect',
        _scheme='https',
        _external=True
    )
    scopes = ('openid', 'email', 'profile')

    # Add the generated CSRF token to the client session for later validation.
    session[CSRF_KEY] = csrf_token

    # Generate authorization URL
    params = dict(
        client_id=current_app.config.get('GOOGLE_OIDC_CLIENT_ID'),
        scope=' '.join(scopes),
        response_type='code',
        access_type='online',  # Because we don't need a refresh token.
        state=csrf_token,
        nonce=nonce,  # Enable replay attack protection attack.
        redirect_uri=redirect_uri
    )
    if hosted_domain:
        params['hd'] = hosted_domain

    urlencoded_params = urlparse.urlencode(params)
    google_authorization_url = '{}?{}'.format(auth_uri, urlencoded_params)
    return google_authorization_url
def get_oauth2_authorize_url ( hosted_domain = None ) : auth_uri = current_app . config . get ( 'GOOGLE_OIDC_AUTH_URL' , AUTH_URI ) csrf_token = _generate_random_token ( ) nonce = _generate_random_token ( ) redirect_uri = url_for ( 'user_views.google_openid_connect' , _scheme = 'https' , _external = True ) scopes = ( 'openid' , 'email' , 'profile' ) # Add the generated CSRF token to the client session for later validation. session [ CSRF_KEY ] = csrf_token # Generate authorization URL params = dict ( client_id = current_app . config . get ( 'GOOGLE_OIDC_CLIENT_ID' ) , scope = ' ' . join ( scopes ) , response_type = 'code' , access_type = 'online' , # Because we don't need a refresh token. state = csrf_token , nonce = nonce , # Enable replay attack protection attack. redirect_uri = redirect_uri ) if hosted_domain : params [ 'hd' ] = hosted_domain urlencoded_params = urlparse . urlencode ( params ) google_authorization_url = '{}?{}' . format ( auth_uri , urlencoded_params ) return google_authorization_url