Auth0 Lock - Google oauth2无法获得refresh_token

时间:2016-12-14 00:54:25

标签: authentication oauth-2.0 google-oauth2 auth0

我正在使用带有google-oauth2连接的Auth0 Lock,我需要获得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

1 个答案:

答案 0 :(得分:2)

这条规则是错误的。 IdP access_tokens可通过管理API获得。请参阅此端点:https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id

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

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

  

您当然可以从规则中调用API,但我们可能会建议不要使用它,而是让您的后端代表您的(前端)应用程序行事。

相关问题