Firebase OAuth client ID provided is either invalid Error - swift

I have been using Firebase Auth (phone) in the app for a long time and have never had a problem
Today a user got that error on iOS device
The OAuth client ID provided is either invalid or does not match the specified API key
Since only one user got this error, I need to debug this carefully
PhoneAuthProvider.provider().verifyPhoneNumber(
number.getFormattedPhoneNumber(format: .E164)!,
uiDelegate: nil,
completion: { verificationID, error in
DispatchQueue.main.async {
if let error = error {
//print error
}
//logic
}
})
I use the above code to verify the phone number
What could cause that error on that user's device?
EDIT: I updated the app with iOS 15 SDK Xcode and the user that had this issue has iOS 14, could be any relation between them?

Related

Can you validate whether a user has been recently authenticated on Firebase (Swift)?

Is there a way to check if a user has recently authenticated on Firebase to avoid this message when trying to delete a user: "This operation is sensitive and requires recent authentication. Log in again before retrying this request."
I have been playing around trying to compare lastSignInDate (below) to current time but there seems to be a large margin of error on this which can cause problems:
firebase.auth().currentUser.metadata.lastSignInTime
Are there any functions that can return a simple boolean as to whether a user has recently authenticated so the user.delete() function will work properly?
Thanks so much!
The best way to do this is by checking if the response has an error, like so:
let user = Auth.auth().currentUser
user.delete { error in
if let error = error {
if (error.code == "auth/requires-recent-login") {
// The user's credentials are too old. Prompt Login screen.
}
} else {
// ...
}
}
According to Firebase Documentation, There's no other approach to this other than comparing the current date with firebase.auth().currentUser.metadata.lastSignInDate (Only if you have the Admin SDK on your app, but you most probably do not need that for enabling a user to delete themselves).

Apple Music API not letting me get User Token - Throwing Unknown Error

I am trying to create a very simple app using Apple's Apple Music API in Swift. To do this, I need to retrieve songs from Apple Music. I am trying to get a user token using this code
SKCloudServiceController().requestUserToken(forDeveloperToken: "[DEV TOKEN HERE]") { (userToken, err) in
if let e = err {
print(e)
}
if let token = userToken {
print(token)
}
}
Right now I am just trying to print the token, but every time I call this function I am met with this error in console
Error Domain=SKErrorDomain Code=0 "An unknown error occurred" UserInfo={NSLocalizedDescription=An unknown error occurred}
I am confident that it is not my Dev Token because that usually throws a 'Cannot Connect to iTunes' error and I have tried substituting random strings for my dev token just to get the same error.
I've looked around but I cannot find an answer to this, has anyone else encountered it or have any idea how to fix it?
Thank you!
P.S I am not too familiar with posting on Stack Overflow so if I made some mistake please let me know so I can correct it!
Same here. It worked before 14.2. Developer Token is valid, I checked Dev Center.

HealthKit Authentication Error (Code = 3)

When I try to authenticate access to write to a user's mindful minutes store (health app) from the onboarding in my own app, the authentication page doesn't display (although I did have this working in previous versions of the app). The app however doesn't crash and there is only the following message in the debugger:
Error Domain=com.apple.healthkit Code=3 "Failed to look up source with bundle identifier "com.myorg.myapp"" UserInfo={NSLocalizedDescription=Failed to look up source with bundle identifier "com.myorg.myapp"}
The code I am using to request the authentication is as follows:
let typesToShare = Set([
HKObjectType.categoryType(forIdentifier: HKCategoryTypeIdentifier.mindfulSession)!
])
self.healthStore.requestAuthorization(toShare: typesToShare, read: nil) { (_, error) -> Void in
if let error = error {
print("\(error)")
}
DispatchQueue.main.async {
self.performSegue(withIdentifier: "openWalkthroughThree", sender: self)
}
}
I have searched around the internet but can't seem t find anyone with the same issue. I have also checked my entitlements for HealthKit as well as usage description but they both seem to be fine - as I said, I had this working in previous versions of my app.
I would be grateful for any help you could give me in finding a solution to this problem.
Not sure what's going on but simply restarting my device fixed this issue.
Also see: Missing HealthKit Entitlement

Passwordless Email Auth Firebase, Dynamic Links (FDL)

I'm trying to setup password-less email authentication through firebase for my iOS app. I'm using the method send signInLink which require actionCodeSettings and in turn a url. I've discovered that this url has to be a dynamic link created on Firebase. I've gone to the firebase console and white-listed a domain, but when I try to create the dynamic link on the console, I get "An error occurred when creating new dynamic link".
I'm a little confused as to how I'm supposed to construct this dynamic link especially the deep link. I've been through Firebase's documentation, added a dummy App Store ID and App prefix (as I was told by Firebase support), but I can't seem to get a proper diagnosis behind this
If I try sending the sign-in email there is no issue, but when I click on the link I get a 400 error saying "The requested URL was not found on this server".
Can anyone help me out with this?
actionCodeSettings.handleCodeInApp = true
actionCodeSettings.url = URL(string: String(format: "my_dynamic_link", email.text!))
actionCodeSettings.setIOSBundleID(Bundle.main.bundleIdentifier!)
actionCodeSettings.setAndroidPackageName("", installIfNotAvailable: false, minimumVersion: "12")
Auth.auth().sendSignInLink(toEmail: email.text!, actionCodeSettings: actionCodeSettings, completion: { error in
if error != nil {
print("Link Error: " + (error?.localizedDescription)!)
let castedError = error as NSError?
let FBError = AuthErrorCode(rawValue: (castedError?.code)!)
switch FBError {
case .invalidEmail?:
print("invalid email")
case .emailAlreadyInUse?:
print("in use")
default:
print("Create User Error: \(error!)")
}
}
else {
print ("No Error")
}
})
You could try following the troubleshooting steps mentioned in the Firecasts video "Getting started with Firebase Dynamic Links on iOS - Pt.1 (Firecasts)" at 7:54 (https://youtu.be/KLBjAg6HvG0?t=474).
I was having the same issue and everything worked fine after:
deleting the app
restarting my phone
reinstalling the app
Currently the bug radar (http://www.openradar.me/radar?id=4999496467480576) is still open.

Facebook login WinJS Store app issues

I tried following this blog post
Which explains how to setup up facebook login on a WinJS app.
I got it all working, got the app ids set and the authentication dialog is showing the correct app name and authentication stuff, however when the app redirects the app receives this error (after closing the dialog: "The specified protocol is unknown") and the dialog shows the error message: "We can't connect to the service you need right now. Check your network connection or try this again later".
the error stack:
"WinRTError: The specified protocol is unknown.\r\n\n at getResultsOfAsyncOp (Function code:338:5)\n at op.completed (Function code:427:21)
Actual calling code:
var loginURL = "https://www.facebook.com/dialog/oauth?client_id=[snip]&display=popup&scope=user_about_me&response_type=token&redirect_uri=ms-app://s-[snip]/"
Windows.Security.Authentication.Web.WebAuthenticationBroker.authenticateAsync(
Windows.Security.Authentication.Web.WebAuthenticationOptions.none,
new Windows.Foundation.Uri(loginURL))
.then(function success(result) {
}, function error(error) {
});
Hopefully anyone here has any idea why this error message is thrown.
We managed to solve the issue.
The sid from the store was different from the sid of the app during local debugging. By changing the appmanifest -> packaging -> publisher certificate to a local certificate with the CN provided in the store settings the sid is updated to be equal to the one in the store.
et voila, it works.