internal virtual protected Uri GetLoginUrl(IFacebookApplication settings, HttpContextBase httpContext, IDictionary<string, object> parameters) { Contract.Requires(settings != null); Contract.Requires(httpContext != null); var authorizer = new CanvasAuthorizer(settings, httpContext) { ReturnUrlPath = this.ReturnUrlPath, CancelUrlPath = this.CancelUrlPath, LoginDisplayMode = this.LoginDisplayMode }; if (!String.IsNullOrEmpty(this.Permissions)) { authorizer.Permissions = this.Permissions.Replace(" ", String.Empty).Split(','); } return authorizer.GetLoginUrl(parameters); }
protected internal override System.Uri GetLoginUrl(IFacebookApplication settings, HttpContextBase httpContext, IDictionary<string, object> parameters) { var authorizer = new CanvasAuthorizer(settings, httpContext) { ReturnUrlPath = ReturnUrlPath, CancelUrlPath = CancelUrlPath, LoginDisplayMode = LoginDisplayMode }; if (!String.IsNullOrEmpty(Permissions)) { authorizer.Permissions = Permissions.Replace(" ", String.Empty).Split(','); } if (string.IsNullOrEmpty(CancelUrlPath)) { // set it to this same url instead of going to facebook.com var canvasUrlBuilder = new CanvasUrlBuilder(settings, httpContext.Request); var currentPathAndQuery = canvasUrlBuilder.CurrentCanvasPathAndQuery; if (currentPathAndQuery.Contains("?")) { var parts = currentPathAndQuery.Split('?'); if (parts.Length == 2 && !string.IsNullOrEmpty(parts[1])) { var queryStrings = FacebookUtils.ParseUrlQueryString(parts[1]); // remove oauth 2 error querystrings. // error_reason=user_denied&error_denied=access_denied&error_description=The+user+denied+your+request. if (queryStrings.ContainsKey("error_reason")) { queryStrings.Remove("error_reason"); } if (queryStrings.ContainsKey("error_denied")) { queryStrings.Remove("error_denied"); } if (queryStrings.ContainsKey("error_description")) { queryStrings.Remove("error_description"); } currentPathAndQuery = parts[0] + "?" + FacebookUtils.ToJsonQueryString(queryStrings); } } authorizer.CancelUrlPath = currentPathAndQuery; } return authorizer.GetLoginUrl(null); }