2016-09-20 5 views
2

Ich versuche den Facebook Login in iOS 10 App mit swift 3.0 zu integrieren. i bekommen Fehlercode 2500, wie unten nach der Installation der FacebookSDK in der App angezeigt:Fehlercode 2500 Facebook Login auf Swift 3.0

Fehlercode auf der Konsole:

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 Funktion auf loginViewController:

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

    fetchProfile() 
    print("@@@@Completed [email protected]@@@") 

} 

Holen Facebook Profil-Funktion auf 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(requestError) 
      print("There are some error during getting the request from fb") 
      return 
     } 

     self.email = (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) 
     print(self.lastName) 

     var pictureUrl = "" 

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

    }) 
} 

AppDelegate.swift

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) 
} 

Hatte Suche nach ähnlichen Frage auf Stack-Überlauf, aber nicht arbeiten flink 3.0, würde schätzen, wenn jemand auf dieses Problem dank beraten könnte und haben eine schöne Tag!

Antwort

1

ich das Problem gelöst hatte, wie der Schlüsselbund der Zugriff standardmäßig in iOS10, Aktivieren Sie die KeyChain Freigabe unter Capabilities und Facebook-Login funktioniert perfekt deaktiviert!

1

Wie die Fehlermeldung besagt, fehlt das access_token. Machen Sie ein Steuerelement, bevor Sie eine Anfrage stellen, und überprüfen Sie, ob access_token null ist, und fordern Sie dann eine neue an. Danach sollten Sie in der Lage sein, Ihre Anfragen zu stellen.

+1

mit Dank erwähnt! – aznelite89

Verwandte Themen