如何通过 ueberauth_google 提交 prompt=consent

How to submit prompt=consent via ueberauth_google

当用户已经同意应用程序时(例如,当用户在初次尝试时放弃创建帐户,然后再次尝试),Google 不会重新提示同意,除非 prompt=consent 已通过(参见 documentation)。如果不提示同意,Google 将不会向调用服务器提供刷新令牌。如果没有刷新令牌,服务器将无法与用户的资源进行交互(例如,代表用户发送电子邮件)。

ueberauth_google 具有设置 approval_prompt 的机制,但这是与 prompt 不同的参数。有没有办法使用 ueberauth_google 发送 prompt=consent? (请注意,如果我将 %26prompt%3Dconsent 添加到 ueberauth_google 发送给我的 url,那么 Google 会提示我并且我们的服务器会收到刷新令牌。)

在您的 config.exs 上您需要添加提示:"consent"

config :ueberauth, Ueberauth,
  providers: [
    google:
      {Ueberauth.Strategy.Google,
       [
         access_type: "offline",
         prompt: "consent",
         default_scope:
           "https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/userinfo.profile"
       ]}
  ]

但这还没有合并到 ueberauth_google。目前,你可以去你的: deps/ueberauth_google/lib/ueberauth/strategy/google.ex

并手动编辑此行