I am integrating Firebase Authentication with MongoDB Stitch Custom Authentication on Swift iOS and would like to pass user's information from firebase to mongodb so that user's email or name can displayed on MongoDB's console here:
Base on MongoDB's docs, these can be accessed via the metadata
from the JWT, but I do not know how to add them from iOS. This is how I authenticate from Firebase to Stitch:
Auth.auth().signIn(with: credential) { (results, error) in
if let error = error {
print(error.localizedDescription)
return
}
if let results = results {
results.user.getIDTokenForcingRefresh(true) { (tokenId, error) in
if let error = error {
completion(error)
}
if let tokenId = tokenId {
let credential = CustomCredential.init(withToken: tokenId)
stitch.auth.login(withCredential: credential) { (result) in
switch result {
case .success(let user):
print("Sign in to Stitch successful")
case .failure(let e):
print(e)
}
}
}
}
}
}
}
The above authentication method works and I can authenticate successfully on Stitch. But how can I extract the Provider Data from Firebase and display them on MongoDB?