【问题标题】:Auth0 handling declined permissionsAuth0 处理拒绝的权限
【发布时间】:2016-06-15 12:16:45
【问题描述】:

我的 Auth0 帐户使用 facebook(和其他)登录。

  • 当用户第一次批准fb申请时,他必须批准权限(例如电子邮件)。
  • 用户可以取消选中电子邮件,拒绝电子邮件权限。
  • 他仍然批准了申请,只是没有批准这个权限。

我在 Auth0 规则中检测到这一点并且登录失败,但是当用户再次单击登录时,他没有看到 facebook 批准屏幕并且无法重新批准电子邮件权限。

简而言之,用户被卡住了!唯一的解决方案是手动从用户那里删除应用程序。

有什么想法吗?

一些进展:

我发现 facebook sdk 支持 auth_type:"rerequest" 但是如何将其传递给 Auth0?

【问题讨论】:

    标签: javascript facebook-sdk-4.0 auth0


    【解决方案1】:

    尝试使用prompt=consent 作为查询字符串中的附加参数。如果您正在使用锁定:

    auth0Lock.show({ 
    ...
    authParams: { scope: 'openid offline_access', prompt:'consent' 
    },
    ... 
    })
    

    【讨论】:

    • 怎么样?在哪里?这是我的代码: auth0Lock.show({ callbackURL: window.location.protocol +"//"+ window.location.host , responseType: 'token' , authParams: { scope: 'openid offline_access', device:"web1" , state:"hash:"+window.location.hash+",someParam:123" }, });
    • auth0Lock.show({ callbackURL: window.location.protocol +"//"+ window.location.host , responseType: 'token' , authParams: { scope: 'openid offline_access', device: "web1", state:"hash:"+window.location.hash+",someParam:123", prompt:login }, })
    • 不工作..无论如何它会让fb要求输入密码..不是我需要的
    【解决方案2】:

    终于解决了!

    得到了 auth0 支持的一些帮助

    我们需要设置

    prompt: 'consent'
    

    这里有两个例子:

    使用 Auth0Lock(小部件)对象:

    auth0Lock.show({
      callbackURL: window.location.href,   //where to go back. must allow this url in dashboard
      responseType: 'token', //this will cause the hash to return the token
      authParams: {
        scope: 'openid offline_access',
        prompt: 'consent'   // THIS WILL ASK THE USER TO APPROVE THE PERMISSIONS THAT HE DECLINED EARLIER 
      },
      connection_scopes: {
        'facebook': ['public_profile', 'email'],    //this optional this this example
      }
    
    });
    

    使用 Auth0 对象:

    auth0.login({
          popup: true,  // to use popup and js callback or redirect with hashtag
          connection: 'facebook',
          state:"some_state"
          scope: 'openid offline_access',
          prompt: 'consent'
        },
        //if popup=true then will callback
        function (err, profile, id_token, access_token, state, refreshToken) {
          if (err) {
            console.log("err", err);
          } else {
            console.log(id_token);
          }
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-11
      • 1970-01-01
      • 2017-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多