FBSDKAccessToken currentAccessToken is not being updated after log in
Please check your appDelegate class and implement all the required methods of FB SDK. I am attaching a screenshot for the same.
How to get FBSDKAccessToken from FBSDKAuthenticationToken
According to this blog post of Facebook, limited mode and classic mode use different authentication methods behind.
Limited Login mode is based on the OpenID Connect standard.
Classic Login mode utilizes oAuth 2.0.
Therefore, I think there's no way to get access token by authentication token.
But we can get basic profile of user under limited login mode. There's a code snippet from Facebook's documentation reveals how to do that.
let loginManager = LoginManager()
// Ensure the configuration object is valid
guard let configuration = LoginConfiguration(tracking: .limited, nonce: "123")
else {
return
}
loginManager.logIn(configuration: configuration) { result in
switch result {
case .cancelled, .failed:
// Handle error
break
case .success:
// getting user ID
let userID = Profile.current?.userID
// getting pre-populated email
let email = Profile.current?.email
// getting id token string
let tokenString = AuthenticationToken.current?.tokenString
}
}
Also note that limited login mode does not support Graph API.
Why is [FBSDKAccessToken currentAccessToken] is nil after login in with permissions
For anyone, browsing though this, I was using FSDKLoginButton as an instance variable in order to access it through different routines. That is why it wasn't working. You have to declare the button as google said.
Error:An active access token must be used to query information about the current user
Got it!
This will be surely helpful to someone, Actually i did mistake in this place, [[[FBSDKGraphRequest alloc] initWithGraphPath:url parameters:@{ @"fields": @"id,picture"}]
This method not have the access token ever. But wonder is the access token is not enable in the whole app. it will be null when i move to the next page after kill the app. So i just save the token string in NSUserDefaults like
NSString *access_token=[FBSDKAccessToken currentAccessToken].tokenString;
[NSUSER setObject:access_token forKey:@"fb_token"];
[NSUSER synchronize];
And then wherever i call the graphAPI i use this method with tokenstring like,
[[[FBSDKGraphRequest alloc] initWithGraphPath:url parameters:@{ @"fields": @"id,picture"} tokenString:[NSUSER objectForKey:@"fb_token"] version:nil HTTPMethod:@"GET"]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
{
}];
Simple but it takes too long to find. Glad!
Related Topics
Drop-Down List in Uitableview in iOS
Sorting Nsarray of Dictionaries by Value of a Key in the Dictionaries
Uploading Image with Afnetworking 2.0
iPhone Upload Multipart File Using Afnetworking
Ios: Keep an App Running Like a Service
Framework Not Found Googletoolboxformac
Swift 3.0 Error: Escaping Closures Can Only Capture Inout Parameters Explicitly by Value
In Swift, How to Avoid Both Optionals and Nil Object References
How to Create a Circular Progress Indicator for a Count Down Timer
In Swift, Array [String] Slicing Return Type Doesn't Seem to Be [String]
iOS 7 Sprite Kit Freeing Up Memory
Is Nstimer Expected to Fire When App Is Backgrounded
Prompt When Trying to Dial a Phone Number Using Tel:// Scheme on iOS 10.3
High Quality Scaling of Uiimage
iOS 9 Facebook Login Simulator -Canopenurl: Failed for Url: "Fbauth2:///" - Error: "(Null)"