IPhone / Objective-C - Facebook Single Sign On

I implemented the single-sign feature using the Facebook SDK in my iPhone application, but I'm just wondering how do you know if they have already authenticated and / or accepted permissions?

I noticed that when you check for this application, Facebook always appears and says that you have already authenticated, and you are always forced to click "OK", which is very annoying every time they open the application.

There is an iPhone application called Socialcam, which only asks you to accept permissions, and every time you open the application from that moment, it knows that you have already been authenticated and never asks you again.

I would like to do this, since my application is heavily dependent on Facebook permissions. It uses their profile images and permissions to check (for example) in all different areas of my application.

If I use NSHTTPCookieStorage :

 NSLog(@"%@", [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]); 

He provides me this information. How can I use it to authenticate against the Facebook API?

 ( "<NSHTTPCookie version:0 name:@\"datr\" value:@\"5WqaTXRFMRlijBtMvcGg-wS1\" expiresDate:@\"2013-04-06 07:42:45 +0000\" created:@\"323854917.000000\" sessionOnly:FALSE domain:@\".facebook.com\" path:@\"/\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>", "<NSHTTPCookie version:0 name:@\"locale\" value:@\"en_US\" expiresDate:@\"2011-04-19 09:46:10 +0000\" created:@\"324294323.000000\" sessionOnly:FALSE domain:@\".facebook.com\" path:@\"/\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>", "<NSHTTPCookie version:0 name:@\"m_user\" value:@\"myfacebookusernameishere%3A105339949%3Anwib6jXhKY2tIYjz%3A0%3Aajax_0%2Cwidth_0%3A1302162165\" expiresDate:@\"2011-07-06 07:42:45 +0000\" created:@\"323854917.000000\" sessionOnly:FALSE domain:@\".facebook.com\" path:@\"/\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>" ) 

Any help would be greatly appreciated.

+4
source share
3 answers

Fulvio

I have not looked at my Facebook code for 9 months. So take my answer as a suggestion. However, I just looked at it, and the authentication status is saved in the cookies left after the authorization process. This is pretty easy to write:

 NSLog(@"%@", [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]); 

Enjoy, Andrew

+1
source

cookies sometimes do not help, so use the below

 [facebook requestForGraph:@"me" delegate:self] 

with the new Facebook API

+1
source

I am going to try the following:

Facebook token storage for offline access

0
source

Source: https://habr.com/ru/post/1347837/


All Articles