linkAndRetrieveData not working with Facebook for Firebase Authentication in iOS - ios

First I am calling -
FBSDKLoginManager().logIn(withReadPermissions: ["public_profile", "email"], from: self)
On success getting credential -
let credential = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
Then passing the credential to linkAndRetrieveData -
Auth.auth().currentUser?.linkAndRetrieveData(with: credential)
Getting this error, which says “MISSING_ID_TOKEN” -
{
FIRAuthErrorUserInfoNameKey = "ERROR_INTERNAL_ERROR";
NSLocalizedDescription = "An internal error has occurred, print and inspect the error details for more information.";
NSUnderlyingError = "Error Domain=FIRAuthInternalErrorDomain Code=3 \"(null)\" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={\n code = 400;\n message = \"MISSING_ID_TOKEN\";\n status = \"INVALID_ARGUMENT\";\n}}";
"error_name" = "ERROR_INTERNAL_ERROR";
}
It works fine with -
Auth.auth().signInAndRetrieveData
What I am doing wrong here?

It should be fix soon with Firebase Authentication version 5.4.1. See the issue below:
https://github.com/firebase/firebase-ios-sdk/issues/2522

Related

Facebook OAuthException with 500 (error code 8)

I'm working with the Facebook iOS SDK (version 15).
When logging in and returning to the app, the Facebook SDK keeps throwing this error
▿ Optional<Error>
- some : Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={NSRecoveryAttempter=<FBSDKTemporaryErrorRecoveryAttempter: 0x28219d100>, com.facebook.sdk:FBSDKGraphRequestErrorKey=1, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An unknown error has occurred., com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 1;
"fbtrace_id" = AK1LoNJP0ca0quThgMVlELr;
message = "An unknown error has occurred.";
type = OAuthException;
};
};
code = 500;
}, NSLocalizedRecoveryOptions=(
OK
), com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=500, NSLocalizedRecoverySuggestion=The server is temporarily busy, please try again., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCodeKey=1}
Because of this, Facebook keeps blocking my app, so users cannot log in using Facebook.
Any ideas on what the cause of this could be?

Google SignIn - Always return "The user canceled the sign-in flow"

I am using below code snippet for signin with google, but always returning "The user canceled the sign-in flow"
if GIDSignIn.sharedInstance.hasPreviousSignIn() {
logout()
}else {
guard let clientID = FirebaseApp.app()?.options.clientID else { return }
let signInConfig = GIDConfiguration.init(clientID: clientID)
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: getWindowTopController()) { user, error in
guard error == nil else { return }
guard let authentication = user?.authentication,let idToken = authentication.idToken else { return }
}
Error : Error Domain=com.google.GIDSignIn Code=-5 "The user canceled
the sign-in flow." UserInfo={NSLocalizedDescription=The user canceled
the sign-in flow.}
Could you please help me to resolve this issue.
Try below code
The GIDSignInButton object don't need addTarget in code or linking #IBAction. The GIDSignInButton class already handle that action for us.
Got it from here
How to fix `The user canceled the sign-in flow.` with Sign In with Google on iOS?
If above code not works, try the below one
Custom Google Sign-In button - iOS

NEHotspotConfigurationErrorDomain Code=5 "invalid EAP settings."

I'm using NEHotspotConfigurationManager with on iOS 11 iPhone to connect to specific Wi-Fi spot and then disconnect from it.
Here is the code:
let domainName = ""
let hotspotSettings = NEHotspotHS20Settings.init(domainName: domainName, roamingEnabled: true)
let hotspotEAPSettings = NEHotspotEAPSettings()
hotspotEAPSettings.username = *****
hotspotEAPSettings.password = ******
hotspotEAPSettings.isTLSClientCertificateRequired = true
hotspotEAPSettings.supportedEAPTypes = [21]
hotspotEAPSettings.trustedServerNames = [""]
hotspotEAPSettings.ttlsInnerAuthenticationType = .eapttlsInnerAuthenticationMSCHAPv2
print(hotspotEAPSettings)
let hotspotConfig = NEHotspotConfiguration.init(hs20Settings: hotspotSettings, eapSettings: hotspotEAPSettings)
print( hotspotConfig.ssid)
NEHotspotConfigurationManager.shared.apply(hotspotConfig) {[unowned self] (error) in
print(error?.localizedDescription as Any)// gives Error Domain=NEHotspotConfigurationErrorDomain Code=5 "invalid EAP settings."
print(error as Any)
if let error = error {
self.showError(error: error)
} else {
self.showSuccess()
}
}
Question is: what happened? Why it prompts me error "invalid EAP settings", and also what does this error mean?
For this first we had to save certificate which comes in .mobileconfig file into iPhone keychain in $TeamID.com.apple.networkextensionsharing group, also enable the keychain access group in xCode capability and add $TeamID.com.apple.networkextensionsharing into entitlements.After successfully save the certificate into keychain it works.

Delegation from Auth0 to Firebase does not function

I have a firebase app. Authentication provider is Auth0, all my users are residing in auth0. I am trying to login with auth0 and than with delegation creating a jwt token to use in firebase. But from firebase I am getting an error.
The error is
Login Error happened: Optional(Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={NSUnderlyingError=0x618000252ed0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={
code = 400;
errors = (
{
domain = usageLimits;
message = "Bad Request";
reason = keyExpired;
}
);
message = "Bad Request"; }}}, error_name=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information.})
However, the JWT is okay and the id_token is not expired. The payload is
{
"uid": "auth0|58f1d133c6623f69e82eaccd",
"iat": 1492376288,
"exp": 1492379888,
"aud": "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iss": "firebase-adminsdk-b69t9#mein-dienstplan-6cd8e.iam.gserviceaccount.com",
"sub": "firebase-adminsdk-b69t9#mein-dienstplan-6cd8e.iam.gserviceaccount.com"
}
The code segment show, what I am doing after authenticating teh user with email/password and getting the id_token,
Auth0
.authentication()
.delegation(withParameters: ["id_token": self.id_token!,
"target_client": "116821977303633943003",
"grant_type" : "urn:ietf:params:oauth:grant-type:jwt-bearer",
"scope": "openid profile",
"api_type": "firebase"])
.start { result in
switch(result) {
case .success(let credentials):
if let idToken = credentials["id_token"] as? String {
print("FIREBASE TOKEN = \(idToken)")
FIRAuth.auth()?.signIn(withCustomToken: idToken) { (user, error) in
guard let user = user else {
callback(error)
return
}
print("Firebase user \(user)")
callback(nil)
}
callback(nil)
} else {
callback(UserSessionError.noIdToken)
}
case .failure(let error):
callback(error)
}
}
This code brings the error above.
Anyone has any idea what is wrong ? Thx in advance...

Error when I'm using MailCore2 in Swift 2

I'm using the MailCore2 at Swift in my iOS application to send message to email in the background without open built-in mail application, But when I'm running app on my device ( real device ) I have this problem:
My complete code for send button:
#IBAction func sendButton(sender: AnyObject) {
var smtpSession = MCOSMTPSession()
smtpSession.hostname = "smtp.gmail.com"
smtpSession.username = "from-email"
smtpSession.password = "password"
smtpSession.port = 465
smtpSession.authType = MCOAuthType.SASLPlain
smtpSession.connectionType = MCOConnectionType.TLS
smtpSession.connectionLogger = {(connectionID, type, data) in
if data != nil {
if let string = NSString(data: data, encoding: NSUTF8StringEncoding){
NSLog("Connectionlogger: \(string)")
}
}
}
var builder = MCOMessageBuilder()
builder.header.to = [MCOAddress(displayName: "AAA", mailbox: "to-email")]
builder.header.from = MCOAddress(displayName: "RRR", mailbox: "from-email")
builder.header.subject = messageTitleTextField.text
var message = messageTextView.text
builder.htmlBody = message
let rfc822Data = builder.data()
let sendOperation = smtpSession.sendOperationWithData(rfc822Data)
sendOperation.start { (error) -> Void in
if (error != nil) {
NSLog("Error sending email: \(error)")
} else {
NSLog("Sent successfully, Thanks!")
}
}
}
Error:
Optional(Error Domain=MCOErrorDomain Code=5 "Unable to authenticate with the current session's credentials." UserInfo={NSLocalizedDescription=Unable to authenticate with the current session's credentials.})
Already I change setting of unsecure app from gmail account but I solved the credentials problem by unlocking gmail account from this link
https://accounts.google.com/DisplayUnlockCaptcha
In my case I had to "Change account access for less secure apps"
https://support.google.com/accounts/answer/6010255?hl=en
If somebody has this problem its quite helpful to know that it is actually problem with security on google side and there it has to be handled...I will leave it because when this happened to me the error didn't say anything I had to search for problem to find out that you have to go to that link on google and find out how to setup it correctly, I wasted time , it will be helpful for others who wants to send mail by smtp with google account

Resources