Play Framework追加#_ = _通过OAuth2在Facebook身份验证后重定向 [英] Play Framework appending #_=_ to redirect after Facebook auth via OAuth2?

查看:169
本文介绍了Play Framework追加#_ = _通过OAuth2在Facebook身份验证后重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Play Framework调用OAuth2 :: retrieveAccessToken()之后,我正在做一个简单的重定向。我在URL中添加了有趣的字符,我从来没有放在那里,所以结果如下:


http:// localhost:9000 /#_ = _


#_ = _来自哪里?这是路由文件中的路由定义:


GET / Application.index


这是处理Facebook身份验证的控制器的代码片段:

  public static void facebookConnect (){
OAuth2 facebook = new OAuth2(
https://graph.facebook.com/oauth/authorize,
https://graph.facebook.com/oauth/ access_token,
2 ############ 6,
c ################### ########## 2
);

if(OAuth2.isCodeResponse()){
OAuth2.Response oauthResponse = facebook.retrieveAccessToken(facebookAuthUrl());
if(oauthResponse.error == null){
// ...某处某处会导致#_ = _被附加到URL上?
Application.index();
}
}
facebook.retrieveVerificationCode(facebookAuthUrl());
}

编辑:



根据此页面,Facebook最近更改了API,将 = 如果request_uri为空,那么问题是...我的request_uri已经被明确设置了

解决方案

在安全更新后。



Facebook开发人员博客< a>:


更改会话重定向行为



这个星期,当这个字段留空时,我们开始添加一个片段#_ = _ 到redirect_uri
。请确保您的应用程序可以处理
此行为。



I'm doing a simple redirect after calling OAuth2::retrieveAccessToken() with Play Framework. I'm having funny characters appended to the URL that I never put there, so the end result looks as follows:

http://localhost:9000/#_=_

Where on earth does the #_=_ come from? Here's my route definition from the routes file:

GET / Application.index

Here's the code snippet of the controller dealing with the Facebook authentication:

public static void facebookConnect() {
    OAuth2 facebook = new OAuth2(
        "https://graph.facebook.com/oauth/authorize",
        "https://graph.facebook.com/oauth/access_token",
        "2#############6",
        "c##############################2"
    );

    if(OAuth2.isCodeResponse()) {
        OAuth2.Response oauthResponse = facebook.retrieveAccessToken(facebookAuthUrl());
        if(oauthResponse.error == null) {
            //... Somewhere here, something is causing #_=_ to be appended to the URL?
            Application.index();
        }
    }
    facebook.retrieveVerificationCode(facebookAuthUrl());
}

EDIT:

According to this page, Facebook changed their API recently to include the = if request_uri is empty, the problem is...my request_uri has been explicitly set?

解决方案

This was added after a security update.

From the Facebook developer blog:

Change in Session Redirect Behavior

This week, we started adding a fragment #_=_ to the redirect_uri when this field is left blank. Please ensure that your app can handle this behavior.

这篇关于Play Framework追加#_ = _通过OAuth2在Facebook身份验证后重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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