aznelite89 aznelite89 - 1 year ago 143
Swift Question

Error code 2500 Facebook login on Swift 3.0

I am trying to integrate the Facebook login into iOS 10 app with swift 3.0.
i getting error code 2500 as shown below after setup the FacebookSDK into the app:

error code on console:

body = {
error = {
code = 2500;
"fbtrace_id" = FpAkfsaBAFc;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
code = 400;

loginButton function on loginViewController:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {

print("@@@@Completed Login@@@@")


Fetch Facebook Profile function on loginVC:

func fetchProfile() {

let parameters = ["fields": "email, first_name, last_name, picture.type(large)"]

FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: { (connection, user, requestError) -> Void in

if requestError != nil {
print("There are some error during getting the request from fb")
} = (user?["email"] as? String)!
self.firstName = (user?["first_name"] as? String)!
self.lastName = (user?["last_name"] as? String)!

self.nameLabel.text = "\(self.firstName) \(self.lastName)"
print("My fbname is " + self.firstName)

var pictureUrl = ""

if let picture = user?["picture"] as? NSDictionary, let data = picture["data"] as? NSDictionary, let url = data["url"] as? String {
pictureUrl = url



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.

FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

return true

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)

Had search for similar question on stack overflow, but not working on swift 3.0, Would be appreciated if anyone could advise on this issue, thanks and have a nice day!

Answer Source

As the error message states, you´re missing the access_token. Make a control before you make a request and check if access_token is nil, then request for a new one. After that you should be able to make your requests.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download