Reputation: 81
I am trying to allow the user to login with Instagram, than create a user in Firebase.
This is my code to login
oauthswift.authorizeWithCallbackURL(
NSURL(string: "Testing://oauth-callback")!,
scope: "likes+comments", state:"INSTAGRAM",
success: { credential, response, parameters in
self.token = credential.oauth_token
print(self.token)
let TokenDefault = NSUserDefaults.standardUserDefaults()
TokenDefault.setValue(self.token, forKey: "token")
FIRAuth.auth()?.signInWithCustomToken(self.token) { (user, error) in
print("Im in")
print(user)
// self.performSegueWithIdentifier("segueHome", sender: self)
}
},
failure: { error in
print(error.localizedDescription)
}
When i print user, it shows nil. And in the firebase console, it doesn't show a new user. im not sure what i am doing wrong?
Upvotes: 3
Views: 3314
Reputation: 892
An October 2016 Firebase blog post shows exactly to do this for a Web app (using Node.js backend), and of course iOS and Android implementations would be similar. They do say to "stay tuned", presumably for another blog post specific to iOS/Android but there's nothing as of this writing.
https://firebase.googleblog.com/2016/10/authenticate-your-firebase-users-with.html
Example code is here: https://github.com/firebase/custom-auth-samples
I may be doing this myself under iOS in the next few weeks, so will add more if I find any gotchas.
Upvotes: 2