Auth0 锁 - Google oauth2 无法获得 refresh_token

Auth0 Lock - Google oauth2 unable to get refresh_token

我将 Auth0 Lock 与 google-oauth2 连接一起使用,我需要获得一个 refresh_token,因为我需要在用户访问时从服务器端进行 API 调用离线。

我正在按照他们的指南进行操作,但它不起作用,refreshToken 始终是 undefined

使用http://cdn.auth0.com/js/lock/10.7.2/lock.min.js

this.lock = new Auth0Lock('...', 'xxx.eu.auth0.com', {
  initialScreen:'login',
  allowedConnections: ['google-oauth2'],
  allowSignUp: false,
  auth: {
    redirect: false,
    responseType: "token",
    params: {
      'access_type': 'offline',
      'approval_prompt': 'force',
    },
  },
  autoclose: true
});

也尝试过 params 'approval_prompt': 'force''prompt': 'select_account consent'

此处说明:https://github.com/auth0/rules/blob/master/rules/google-refresh-token.md

这条规则是错误的。 IdP access_tokens 可通过管理 API 使用。查看此端点:https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id

需要特殊范围 (read:user_idp_tokens)。

这是因为 IdP 令牌是敏感的工件,因此 Auth0 设置了额外的安全层来获取它们。

You can of course call the API from a rule, but we'd likely advise against it and instead have your backend act on behalf of your (front-end) app.