扩展身份验证令牌而不刷新页面 [英] Extend auth token without refreshing the page

查看:79
本文介绍了扩展身份验证令牌而不刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户希望在不刷新浏览器的情况下长时间使用我的facebook应用程序.
但是令牌会在2小时后过期.现在,我要求用户刷新页面,但这很烦人.
我不想问脱机访问权限,因为它会吓到一些用户.

Users want to use my facebook app for many hours without refreshing the browser.
But token expires in 2 hours. Now I ask users to refresh the page but that's annoying.
I don't want to ask offline access permissions because it will scare some users.

最好的解决方案是以某种方式重新登录"并获取新令牌,而无需刷新页面. 有可能吗?

The best solution will be somehow "relogin" and get new token without refreshing the page. Is it possible?

推荐答案

我将订阅到期触发器(我认为这是authResponseChange),然后自动执行另一个登录检查.这不是一个完美的解决方案,因为它可能会自动触发弹出式窗口(例如,如果他们已注销),这会被很多浏览器阻止.相反,您可以在令牌过期时检查他们是否需要完成弹出窗口,并在您的页面上某处显示"Facebook需要您继续注意"的通知,然后仅从其响应中启动弹出窗口,这会阻止弹出窗口被阻止.

I would subscribe to the expiry trigger (I think this is authResponseChange), then automate another login check. It won't be a perfect solution as it could trigger a pop up (if they have logged out for example) automatically, which a lot of browsers may block. You could instead, when the token expires, check if they will need to complete a pop up, and display a notification on your page somewhere saying 'Facebook needs your attention to continue', then only launch the pop up from their response, which would stop the pop up being blocked.

FB.Event.subscribe('auth.authResponseChange', function(response) {
  // do something with response
  FB.login(){
    // refresh their session - or use JS to display a notification they can 
    // click to prevent pop up issues
  }
});

这篇关于扩展身份验证令牌而不刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆