superset4 google auth 怎么填写

在使用 Superset4 进行数据可视化时,启用 Google 认证(Google Auth)是确保账户安全的重要步骤。然而,许多用户在配置过程中遇到了各种问题,尤其是不清楚 Superset4 Google Auth 怎么填写。本文将详细讲解如何正确填写 Superset4 的 Google Auth 配置,让您的 Superset4 环境更加安全和高效。

一、为什么要使用 Google Auth 进行认证?

在 Superset4 中,用户通常需要登录才能访问数据仪表盘。使用 Google Auth 进行认证可以带来以下好处:

  1. 提高安全性:避免使用弱密码,提高账户安全性。
  2. 方便管理:无需额外创建和管理用户账户,使用已有的 Google 账号进行登录。
  3. 单点登录(SSO):支持与其他 Google 服务无缝集成,提高用户体验。

二、Superset4 Google Auth 怎么填写?

1. 生成 Google OAuth 2.0 凭证

要在 Superset4 中启用 Google Auth,首先需要在 Google Cloud Platform (GCP) 控制台中创建 OAuth 凭证。

步骤 1:创建项目

  1. 访问 Google Cloud Console
  2. 创建一个新的项目,或者选择一个现有项目。
  3. 确保已启用“Google Identity Platform”。

步骤 2:创建 OAuth 2.0 客户端 ID

  1. 在 GCP 控制台,进入 API & Services > 凭据
  2. 点击 创建凭据,选择 OAuth 2.0 客户端 ID
  3. 应用类型 中选择 Web 应用
  4. 在“授权重定向 URI”中填写:
    http://your-superset-domain.com/oauth-authorized/google
  5. 创建后,记录下 Client IDClient Secret

2. 配置 Superset4 的 Google Auth

在 Superset4 的 superset_config.py 文件中,填写以下内容:

from flask_appbuilder.security.manager import AUTH_OAUTH

AUTH_TYPE = AUTH_OAUTH

OAUTH_PROVIDERS = [
    {
        'name': 'google',
        'icon': 'fa-google',
        'token_key': 'access_token',
        'remote_app': {
            'client_id': '<你的 Google Client ID>',
            'client_secret': '<你的 Google Client Secret>',
            'api_base_url': 'https://www.googleapis.com/oauth2/v2/',
            'client_kwargs': {
                'scope': 'email profile',
            },
            'access_token_url': 'https://oauth2.googleapis.com/token',
            'authorize_url': 'https://accounts.google.com/o/oauth2/auth',
        }
    }
]

3. 配置 ENV 变量

config.py 文件或环境变量中设置:

export OAUTHLIB_INSECURE_TRANSPORT=1  # 仅用于开发环境
export AUTH_TYPE=AUTH_OAUTH

4. 启动 Superset 并测试登录

  1. 重新启动 Superset 服务器:
    superset run -p 8088 --debugger --reload
  2. 访问 Superset 登录页面,点击 Google 登录
  3. 如果配置正确,您将被重定向到 Google 认证页面,输入 Google 账号后,即可成功登录。

三、常见问题及解决方案

1. 登录时报错 “invalid client ID”

解决方案

  • 确保 client_idclient_secret 填写正确。
  • 确保 OAuth 2.0 客户端已启用。

2. 登录成功但没有权限访问 Superset

解决方案

  • superset_config.py 中添加默认角色:
    AUTH_USER_REGISTRATION = True
    AUTH_USER_REGISTRATION_ROLE = 'Gamma'

3. 登录后跳转回 Superset 页面时出错

解决方案

  • 确保 AUTH_TYPE = AUTH_OAUTH 配置正确。
  • 确保 Google API 中 Authorized Redirect URIs 配置了正确的 URL。


Leave a Reply

Your email address will not be published. Required fields are marked *

Search

About

MWT Media Blog brings you the latest SEO news, market trends, and actionable insights to help brands, marketers, and publishers stay ahead in a fast-changing digital landscape. From algorithm updates to outreach strategies, we break down what really matters.

Stay updated with SEO news, trends, and insights shaping the digital marketing world. Practical updates, real strategies, and market-focused analysis—no fluff.

Categories

Tags

Gallery