简体   繁体   中英

facebook application redirects to redirect_uri location

Let me put my code first string strSigned = Request.Params["signed_request"]; // JSONObject obj = JSONObject.CreateFromString(strSigned);

            Facebook.FacebookSignedRequest fb = FacebookSignedRequest.Parse(AppSecret, strSigned);

            JsonObject jsonObj = fb.Data as JsonObject;

            if (!jsonObj.ContainsKey("user_id"))
            {
                string appId = App_Id;


                string redirectUrl = "http://127.0.0.1/Default.aspx"

                string redirectstr = "https://www.facebook.com/dialog/oauth?client_id=" + appId + "&redirect_uri=" + redirectUrl + "&scope=email,read_stream";

                Page.ClientScript.RegisterStartupScript(this.GetType(), "redirect", "<script>top.location.href='" +redirectstr +"'</script>");

                Response.Clear();
            }
            else
            {
                Response.Write(jsonObj["user_id"].ToString());
            }

Above code runs perfectly untill user press allow permissions.the application is actually redirecting to the mentioned redirect_uri http:... and not staying within facebook.

i am really bugged with this.let me know the solution.

It is made this way so that it can be used by external sites which accept facebook login.

The redirect_uri can be set to:

apps.facebook.com/myapp/

or

www.facebook.com/pageurl?sk=app_YOUR_APP_ID

along with external site url.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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