app going to unknown state and doesn't do anything i'm having this code in didFinishLaunchingWithOptions for P2Auth2 and can't authorise
Authenticator.sharedInstance.oauth2 = OAuth2
Authenticator.sharedInstance.reauthorizeSilently(callback: { (wasFailure, error) -> Void in
if (!wasFailure) {
print("Re-Auth Successfull")
} else {
print("Re-Auth failed")
}
})
return true
As tvOS does not support web views, it seems unlikely that you will be able to directly log in from AppleTV. Most AppleTV solutions that succeed use a second device to acquire the OAuth login token. If you can authenticate directly without using OAuth2, I recommend that you do so.
Related
My App uses the Firebase Auth SDK (10.4.0) to authenticate users with OAuth. In my project settings I enabled OpenID Connect as a Sign-In-Method. I use an education institute named "IServ" as my openid auth provider. They have provided me with the ClientID, Issuer-URL and the Client Secret which I entered in the firebase console. I am able to launch the login form of my provider in a WebView with the following code:
let oAuthProvider = OAuthProvider(providerID: "oidc.iserv")
oAuthProvider.scopes = ["roles"]
oAuthProvider.getCredentialWith(nil) { credential, error in
print(credential, error)
}
After entering the login information in the login form of my provider and pressing continue the browser strangely redirects to a white webpage and after a few seconds it redirects to "about:blank".
I have two iOS Apps that are both connected to the same Firebase project. In one of the two apps the oauth login is working and the user gets redirected to the app (i.e. the WebView closes automatically). But in my other app the redirect is not working, although its the exact same code.
I can't retrieve any error in my Xcode console, nor in the WebView. Is this a common issue and has this something to do with the Xcode project setup?
I would really appreciate some help regarding this.
I had the same issues in a SwiftUI app, which I solved with the following approach.
Just before the about:blank is loaded, the app's callback onOpenURL is called (it's just the SwiftUI version of UIApplicationDelegate application:openURL:options).
In the callback, add the following code that triggers the authentication flow continuation:
.onOpenURL { url in
let authCanHandle = Auth.auth().canHandle(url)
if authCanHandle {
return
}
/* Here other dynamic link stuff */
}
This did the trick, for AppDelegate add the following code
func application(_ app: UIApplication, open url: URL, options: func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let twitterhandeled = Auth.auth().canHandle(url)
return twitterhandeled
}
I am trying to enable Facebook authentication in Realm Sync, but keep getting an error on login.
I have been using these guides:
https://docs.realm.io/sync/v/3.x/using-synced-realms/user-authentication/additional-providers#facebook
https://docs.realm.io/sync/v/3.x/self-hosted/customize/authentication/included-third-party-auth-providers/facebook-authentication
I have the Access Token provided by the Facebook API/SDK enabling me to log in/sign up a user.
When I use Realm's libraries to log in a user with the Facebook Access Token, I get an error stating the 'provider' parameter is invalid, but this parameter is defined by Realm's own classes.
I have successfully authenticated a user with an email & password so do I need to set up something else on Facebook/Realm Sync? It seems Facebook authentication just doesn't work in Realm Sync and the above help files are pretty useless.
Authentication code
func authenticateWithFacebook(facebookToken: String, completion: #escaping (RealmAuthenticationResult) -> ()) {
let credentials = SyncCredentials.facebook(token: facebookToken)
print("------FACEBOOK LOGIN-------")
print("Token: \(facebookToken)")
login(credentials) { (result, userId) in
completion(result)
}
}
private func login(_ credentials: SyncCredentials, completion: #escaping (RealmAuthenticationResult, String?) -> ()) {
SyncUser.logIn(with: credentials, server: RealmConnection.AUTH_URL, onCompletion: { (user, err) in
if let _ = user {
print("User has logged in/signed up")
return completion(RealmAuthenticationResult.success(true), user?.identity)
} else if let error = err {
print(error.localizedDescription)
return completion(RealmAuthenticationResult.failure(error), user?.identity)
}
})
}
The error
Error Domain=io.realm.sync.auth Code=601 "Your request parameters did
not validate. provider: Invalid parameter 'provider'!;"
UserInfo={NSLocalizedDescription=Your request parameters did not
validate. provider: Invalid parameter 'provider'!;}
Other things I have tried
I have tried directly instantiating the base provider class 'RLMIdentityProvider' and creating SyncCredentials with that, but no dice.
A workaround is to get the account information from the Facebook API/SDK and use the account's email to login/signup with a username/password setup. However, it seems to make Facebook authentication redundant.
That Realm Documentation link is outdated. See the 3.16.0 Documentation (or later) as a lot was changed.
At the moment Password, JWT & Firebase are the only auth options with Firebase Authentication being a very solid solution. Integrating Firebase is also covered in the Realm Documentation in the Using Sync'd Realms -> Authentication section. I won't link it as the documentation is being frequently updated now days.
As stated by the Realm Team (several times) extensive auth options are not a priority as other companies (like Firebase) handle it very well.
There were a number of posts on the Realm forums speaking to this but Ian's response to this question is very succinct.
we have and will continue to prioritize synchronization features for
mobile
and then
This is why we recommend that a production app should outsource user
management and authentication to a company which specialized in these
features.
I have an inherited Ionic framework app that is using Ionic.io
The app authorises against our API, and is given an API token to use in future requests.
I'm trying to work on push notifications - I've set up ionic push, and can trigger push notifications out to all users with no problems.
I'd like the ability to target specific users / devices to send notifications, and I understand that to do this, I have to register the device to generate a token.
Within my $ionicPlatform.ready function, I have:
$ionicPush.register().then(function(t) {
return $ionicPush.saveToken(t);
}).then(function(t) {
console.log('Token saved:', t.token);
});
This however does not seem to be returning a token, and calling
console.log($ionicPush);
Shows that the token is not set.
Any ideas here? What am I missing?
So after digging though some documentation, I found that the issue was linked with the ionic user.
In the main run function, I fire off a
if ($ionicAuth.isAuthenticated()) {
If this fails, I try a login of a user, and a register of the user if appropriate. (user is already logged in using a custom auth token against our api)
Before I attempt to register the token, I then have to reload the user in order to have the app save off and push back up to ionic.io.
$ionicUser.load().then(function() {
$ionicPush.register().then(function(t) {
console.log('Token sent:', t.token);
return $ionicPush.saveToken(t);
}).then(function(t) {
console.log('Token saved:', t.token);
});
});
I want to add Facebook login to my Alloy/ Titanium ios app.
So far I have the following code:
var fb = require('facebook');
fb.initialize();
fb.setLoginBehavior(fb.LOGIN_BEHAVIOR_NATIVE);
fb.permissions = ['email', 'public_profile'];
function doFacebookLogin() {
// occurs when a button is clicked
if (fb.loggedIn) {
facebookLogin(fb);
} else {
fb.authorize();
}
}
fb.addEventListener('login', function(event) {
if (event.success) {
facebookLogin(fb);
}
});
function facebookLogin(fb) {
Ti.API.info(fb.accessToken);
// send the fb.accessToken server-side and register & login the user
}
For the most part the code works fine!
The issue is when the user de-authorises the app, fb.login still return true and so is using the same access token.
How can I check if the user has de-authorised my app. I know it's easily possible using the JavaScript SDK using FB.getLoginStatus: https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus , but I can't find an equivalent in Alloy/Titanium: https://docs.appcelerator.com/platform/latest/#!/api/Modules.Facebook
You need to call fb.logout() to set fb.loggedIn to false.
fb.logout clears the access token and resets the login state to false.
Note: I am not sure whether clearing the access token in Titanium module will also clear the token on FB server. So even after calling fb.logout(), you might receive the same access token if and only if it has not expired on fb server.
Read more about Facebook Access Token here
Hi i'm trying to start working with Firebase and Swift, but i'm having some troubles authenticating users and making it persistent across app restarts.
I'm using Twitter authHelper which when authenticated returns a FAuthData object containing the user's uid and all those things.
The thing is when i (or the system) kill the app all the authentication thing blows away and i need to relogin because i'm not storing the "authData" object.
How should i do it?
Thank you so much
The best way to do this is using NSUserDefaults. This can be done in the following way (this assumes you are using FIRAuth but Twitter login will give you the same authData):
FIRAuth.auth()!.createUserWithEmail(email, password: pwd, completion: { authData, error in
if error == nil {
//enable automatic login for future usage
NSUserDefaults.standardUserDefaults().setValue(authData?.uid, forKey: "uid")
})
When the user opens the app the next time, do the following check to see whether or not the user has logged in before:
if NSUserDefaults.standardUserDefaults().valueForKey(KEY_UID) != nil {
dispatch_async(dispatch_get_main_queue()) {
[unowned self] in
self.performSegueWithIdentifier(SEGUE_LOGGED_IN, sender: nil)
}
}