Facebook.FacebookOAuthClient.BuildExchangeCodeForAccessTokenParameters C# (CSharp) Method

BuildExchangeCodeForAccessTokenParameters() private method

private BuildExchangeCodeForAccessTokenParameters ( object>.IDictionary parameters, string &name, string &path ) : object>.IDictionary
parameters object>.IDictionary
name string
path string
return object>.IDictionary
        private IDictionary<string, object> BuildExchangeCodeForAccessTokenParameters(IDictionary<string, object> parameters, out string name, out string path)
        {
            name = FacebookUtils.DOMAIN_MAP_GRAPH;
            path = "oauth/access_token";

            var pars = new Dictionary<string, object>();
            pars["client_id"] = AppId;
            pars["client_secret"] = AppSecret;
            pars["redirect_uri"] = RedirectUri ?? new Uri("http://www.facebook.com/connect/login_success.html");
            pars["code"] = null;

            var mergedParameters = FacebookUtils.Merge(pars, parameters);

            if (mergedParameters["client_id"] == null || string.IsNullOrEmpty(mergedParameters["client_id"].ToString()))
            {
                throw new Exception("ClientID required.");
            }

            if (mergedParameters["client_secret"] == null || string.IsNullOrEmpty(mergedParameters["client_secret"].ToString()))
            {
                throw new Exception("ClientSecret required");
            }

            if (mergedParameters["redirect_uri"] == null || string.IsNullOrEmpty(mergedParameters["redirect_uri"].ToString()))
            {
                throw new Exception("RedirectUri required");
            }

            if (mergedParameters["code"] == null || string.IsNullOrEmpty(mergedParameters["code"].ToString()))
            {
                throw new Exception("code required");
            }

            // seems like if we don't do this and rather pass the original uri object,
            // it seems to have http://localhost:80/csharpsamples instead of
            // http://localhost/csharpsamples
            // notice the port number, that shouldn't be there.
            // this seems to happen for iis hosted apps.
            mergedParameters["redirect_uri"] = mergedParameters["redirect_uri"].ToString();

            return mergedParameters;
        }