简体   繁体   English

如何在用于OAuth 2注册/登录的Facebook应用中设置“取消URL”?

[英]How to set Cancel url in facebook app used for oauth 2 signup/login?

i am setting up facebook login on my website. 我正在我的网站上设置Facebook登录。

if user likes to join my site using facebook credentials , then when user clicks on sign up/In using facebook he is redirected to the facebook page where he is shown dialog whether he wants to approve permissions or cancel. 如果用户喜欢使用facebook凭据加入我的网站,则当用户单击“ 使用facebook进行注册/登录”时,他将重定向到Facebook页面,在该页面上会显示对话框 ,提示他是否要批准权限或取消。

like this 像这样

facebook登录oauth权限页面

if he clicks Okay he then redirected to the my site with details forwarded by facebook., 如果他单击“ 确定” ,则将其重定向到我的网站,并提供由Facebook转发的详细信息。

but if he clicks Cancel then he is not redirected to my web site , he stays on the same page while page reloads and he is offered the dialog box again. 但是,如果单击“ 取消”,则不会将其重定向到我的网站,而是在页面重新加载时停留在同一页面上,并再次提供该对话框。

this doesnt feel right, after user clicks cancel he should be redirected to someplace, so how can i set where to redirect the user after he clicks Cancel , on the grant permissions page ? 这感觉不对,在用户单击“取消”后,应该将他重定向到某个地方,那么我如何在用户单击“授予权限”页面上的“取消”后设置重定向用户的位置?

update: other questions on so doesnt have proper answer, so lloking for more acurate answwr. 更新:关于其他问题,所以没有适当的答案,所以等待更准确的答案。

Are you using the Login Button or FB.login()? 您在使用登录按钮还是FB.login()?

If you are using FB.login, you can track the response and whatever choice people make, the browser returns to the app and the response data indicating whether they connected or cancelled is sent to your app. 如果您使用的是FB.login,则可以跟踪响应以及人们做出的任何选择,浏览器将返回到该应用,并将指示他们是否已连接或取消的响应数据发送到您的应用。 You can handle it exactly the way you want it to behave. 您可以完全按照您希望的方式处理它。

FB.login(function(response) {
 if (response.status === 'connected') {
   // Logged into your app and Facebook.
 } else if (response.status === 'not_authorized') {
   // The person is logged into Facebook, but not your app.
 } else {
   // The person is not logged into Facebook, so we're not sure if
   // they are logged into this app or not.
 }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM