Authentication and Authorization combined

May 6, 2010 at 7:39 PM

Does the latest changeset (50207) include support for Facebook's OAuth 2.0? In other words I would like to combine the Login (Authentication) and Extended Permisions (Authorization) into one dialog like this article: http://developers.facebook.com/docs/authentication/

If it does, please post an example on how to use it.

Thanks...

May 6, 2010 at 7:57 PM

I forgot to mention that I'm using an iframe app with webforms. Maybe OAuth is not the way to go as it looks like it is for web apps that reside outside the Facebook Chrome. Either way, I'm trying to accomplish the same thing. Is it doable?

Developer
May 11, 2010 at 4:32 AM
Edited May 11, 2010 at 4:33 AM

It doesn't look like it's in there so here's a quick hack. Copy ConnectSession.cs to OAuthConnectSession.cs and replace the methods GetCookie and GetUserID with the following:

public string GetCookie(string cookieName)
        {
            string fullCookieName = string.Format("fbs_{0}", ApplicationKey);
            if (HttpContext.Current != null
                && HttpContext.Current.Request != null
                && HttpContext.Current.Request.Cookies != null
                && HttpContext.Current.Request.Cookies[fullCookieName] != null)
            {
                var trimmed = Regex.Replace(HttpContext.Current.Request.Cookies[fullCookieName].Value, "^\\\"|\\\"$", "");
                var values = HttpUtility.ParseQueryString(trimmed);
                return values[cookieName];
            }

            return null;
        }

private long GetUserID()
        {
            long userID;
            long.TryParse(GetCookie("uid"), out userID);
            return userID;
        }

 

It's used like how you would normally use the normal ConnectSession. Just that this one will ONLY work on the new OAuth authentication method. So far so good...