I'm looking for a way to save an access token so that a user can post to Facebook without having to log in for every API call:
I need an offline_access token, I store it in NSUserDefaults, but when I try to use it again, I get a FacebookErrDomain 10000 error
That's what I'm doing:
In fbDidLogin I get access_token and keep it default for users
- (void)fbDidLogin { NSString *token = self.facebook.accessToken; [[NSUserDefaults standardUserDefaults] setObject:token forKey:@"facebookToken"]; }
After that, when I run the application again, I just get the token from the user defaults and assign them to the facebook object:
NSString *token = [[NSUserDefaults standardUserDefaults] objectForKey:@"facebookToken"]; [_facebook setAccessToken:token];
But that does not work.
Does anyone know what I can do wrong?
Thanks, Vincent.
EDIT: If I do an NSlog after [[NSUserDefaults standardUserDefaults] objectForKey:@"facebookToken"]; , I will see that the token is saved.
source share