Facebook C# SDK throwing Exceptions on ParseCookieValue - facebook

We're using Facebook connect in an application outside of Facebook, quite regularly the C# Facebook SDK is throwing an exception with this message "Precondition failed: !cookieValue.Contains(",") Session value must not contain a comma."
After doing some research it seems linked to the fact that we're using the JavaScript SDK (for Facebook Connect) and the C# SDK at the same time. As I'm unable to replicate the issue myself I don't have much clue.
UPDATE: In fact the exceptions are happening in prod to "real" users. THE SDK is throwing a hundred of them a day.

Yeah - getting this as well - also using c# SDK and Javascript SDK.
It seems to have happened ONLY to my FB account - when testing my application - and it happened after I had used the wrong app secret in my Oath settings.
It seems that Facebook had TWO access tokens for my personal account - and was trying to store them both in the cookie. I tried using the SDK deleteauthcookie() method, I deleted ALL of Facebook cookies in my browser. No Luck.
The only solution was to remove ALL of the cookies in my browser....
It seems Facebook SOMETIMES tries to store two access tokens in a cookie - separating them with a comma - and c# SDK doesn't like that.

This was a bug in the Facebook C# SDK: http://facebooksdk.codeplex.com/discussions/273578/
Could you remove the following line of code from ParseCookieValue
method.
Contract.Requires(!cookieValue.Contains(","), "Session value must not
contain a comma.");
This has already been fixed in the latest v5.3.1beta
(http://facebooksdk.codeplex.com/releases/view/75790)

Related

Facebook SDK Login - Application Unavailable: The application you're trying to use is either no longer available or access is restricted

A user tried to login to my app using Facebook login and they encountered the following error after being redirected to their native Facebook app: "Application Unavailable: The application you're trying to use is either no longer available or access is restricted".
I'm not able to reproduce it and I haven't found much online. The app is available since it's live under Facebook apps and it's being used by existing users. The only option would be that the access is restricted but I'm not sure why. I do know that Facebook launched a security update in March to "Use Strict Mode for Redirect URIs" by default, but this update does not apply to the Facebook SDK according to what I read.
I had the same error message on Android devices which was caused by setting only development key hashes solved it by adding release key hash, following these instructions: Setting a Release Key Hash on facebook
This error is also produced if you try to sign up with recently created account. It seems like Facebook has some approval process which takes time. For me new account produced an error one day and worked perfectly on the next one.
To test sign up immediately you should create a test user in Facebook App Dashboard under Roles.

Full Facebook PHP SDK app (no JS SDK). Is it even possible?

In my work we often need to build Facebook apps in the form of Facebook Canvas and Website. These apps are available on Facebook direclty (an iframe) and as mobile versions (outside Facebook, in the browser).
We are working with a code base which mixes Facebook JS SDK (authentication and authorization) with PHP SDK (API calls). I find it rather dirty, and not easy to understand for people freshly working on the projects.
It's inconvinient to make API calls with JS, and making them with PHP forces extending access tokens. Authenticating user with JS SDK involves client-side redirects which are ugly to be honest, as they usually occur moments after the current page starts rendering, and so on...
I googled a lot about separating these two SDKs but did not find a clear answer to my questions:
Is it possible to create Facebook app (Canvas, Website) which bases ONLY on PHP SDK? Check login status, login, permissions, making API calls, etc. Would signed request be enough?
Is JS SDK the only full-proof way to determine user's login status at any time?
This link seems to describe what I'm thinking of, however the docs are rather brief (which seems to be a problem of Facebook documentation in general). Can anyone suggest other sources that might help? Does anyone have experience with builing FB aplications based only on server-side?
Thanks.
EDIT:
The link I posted above covers the case of not using ANY SDK, so no, it's not what I'm looking for.
You can even create an App WITHOUT any SDK - with simple CURL calls, for example. So yeah, it is indeed possible to use the PHP SDK only, but the login process is much better with the JS SDK (no redirection needed) and you canĀ“t auto-refresh a user session like it is possible with FB.getLoginStatus afaik.
In short, i would not recommend it, the JS SDK is the very best way to authorize users and refresh Access Tokens. I would only use the PHP SDK (or simple CURL calls) for stuff that MUST happen on the server, and for stuff that includes using the App Secret, for example.

facebook-unity-sdk not working on iOS (facebook-unity-sdk)

I am using Unity Facebook SDK 5.1 and Unity version is 4.3.0.
I am testing on iPhone 4 device which don't have facebook app installed.
I have integrated SDK inside my game.
When i try to login into facebook using my app first it opens the FB login page inside browser,after login it ask me for authorization when i press "Ok" it takes me to my app.
Inside LoginCallBack method i got the following response
FBResult.Text =
{"is_logged_in":false,"user_id":"","access_token":"NOT_USED_ON_IOS_FACEBOOK","access_token_expires_at":"01/01/0001 00:00:00"} .
Many Thanks
Sachet
Make sure that your URLSchemeSuffix in your Info.plist is correct (fb[appid]) and that the handleOpenURL call (in your generated XCode project) is making it back to facebook.
I had the very same problem where another plugin was capturing the handleOpenURL call when i was returning from facebook after authorizing the app and it was preventing the handleOpenURL response from making it all the way back to the facebook plugin.
You can test it by putting a breakpoint in the Facebook/FbUnityInterface.mm file #
- (BOOL)openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication
If this isn't being hit, it's likely another openURL handler is getting the response first and not handing it back to super.
I got the same error but for different reasons using iOS native login.
I checked the URLScheme, add some breakpoints in the different OpenUrl but got nothing. Turns out I was logging with the "publish_actions" permissions. The message meant that this was not supported by iOS native implementation I suppose.
I regret the message not being helpful but you should pay attention to the requested permissions at login and ask them later using the graph API.
Hope that will help people having the same issue.
I got the same error. Reason was in incorrect bundle id (we used different bundle ids for release and development builds). Then we added this bundle id to Facebook App's Settings page, and the error gone.

Facebook access tokens obtained without single sing-on cannot be extended using iOS SDK

I have started to integrate Facebook SDK into my iPhone project. I have no problem on devices with multitasking using SSO. The received access token is long lived and I can extend it by calling the "extendAccessToken" method from Facebook iPhone SDK.
It seems that the access token extension doesn't works on devices without multitasking support. It's very strange, that the "extendAccessToken" method uses an old REST API to extend the token: "auth.extendSSOAccessToken", but the API returns with an error message that says:
"The access token was not obtained using single sign-on". (iPhone 3G)
I have also tried to use the "oath/accesstoken" graph api described on this page: http://developers.facebook.com/docs/offline-access-deprecation but it seems that the returned access token has the same expiration date like before calling this api (I tried to extend the token after 5-6 days since I received it).
Has anybody the same issue?
Maybe this is not a bug but it's a Facebook feature. Maybe the Facebook allows to extend the access token only if it is received through a trusted environment using single sign-on (like Facebook Application or Safari browser).
We had the same issue.
The way we are currently solving it is by having a server extend the access_token.
If anyone has a better solution, would love to hear. If there isn't a better solution and you would like to use our server to extend access tokens, we can work something out.
Yoav.

Facebook authentication with new 'Facebook SDK for iOS' vs. old 'Facebook iPhone SDK'

I'm working on integrating Facebook with my iPhone/iOS application and I want to know if I'm understanding the nature of the login procedure correctly.
With the old Facebook SDK ('Facebook iPhone SDK'), when we needed to request authentication permission from a user a UIWebView would be displayed with a login prompt. With the new SDK ('Facebook SDK for iOS'), the SDK uses Apple's fast-app-switching feature to temporarily place the app in background mode and then load the iOS Facebook app or Safari to authenticate. Is this basically the gist of it?
I've experimented with authenticating my app via the new SDK's technique and due to the nature of my app, it just can't support backgrounding. Does this mean I have to use the old SDK to launch a UIWebView-based authentication? I think this implementation is a lot cleaner anyway. Will I run into any major disadvantages from doing this?
Check out this question and my answer: Iphone facebook connect example calls safari. I don't want to use safari
You can make it use the UIWebView always. Facebook is trying to make it so the user only has to log in once per device (through either the Facebook app or in Safari) but I didn't like this flow (especially on the iPad). Though I'd rather not muck around with the Facebook code, I did find commenting out a few lines to be a quick way of getting the old behavior back.
I don't believe this is the case.
The Facebook SDK that I'm aware of, available at https://github.com/facebook/facebook-ios-sdk doesn't do anything like you describe. Is this the SDK you're using? I believe the last major update to this SDK from the "old" facebook SDK was to add support for OAuth-style authentication. With this change they broke code compatibility so apps were forced to make changes to incorporate the latest SDK.
When you call 'authorize' in this SDK you pass the app id, the desired permissions, and a callback delegate for notifications of errors or success (did login, did not login, did logout). You can also set any access token that you might have persisted from a previous session. Facebook validates this access token, and if it doesn't exist or is invalid it presents a modal login dialog. I believe the content of this dialog is a web page. The SDK authenticates the user using OAuth and makes the auth-token available for persisting between sessions.
At no time is the app exited to run the Facebook app or Safari. I'm curious - what led you to believe this was the case? (Or, perhaps there is some other SDK out there I'm unaware of?)
Take a look on this page: https://github.com/facebook/facebook-ios-sdk
And look at Single Sign-On. That describes the above scenario with fast switching.