Whenever I try to login to facebook using ngCordova ($cordovaOauth) plugin, facebook ask me for my username and password, Is there any way to avoid this behaviour?, I mean It would be nice to just press “Login with facebook” button and if you are already logged in your browser with phone with facebook get this and don’t ask you again to put your password.
This ‘automatic login’ feature is only available through the Cordova Facebook plugin. It’s included in ngcordova, and the docs are extensive. The
$cordovaOAuth plugin will require you to login every time because it opens up a new InAppBrowser every time you try to login again.
I think I will have to include that library in my code, it’s not really nice they always ask you for a username and password.
Thank you for your help.
You can prevent this in
$cordovaOauth by adding some logic of your own.
After your user signs, store the access token and expiration in local storage or sqlite. Then the next time your user clicks the sign in button, check to see if (a) an access token exists and (b) the access token is not expired. Or you can put this logic into place without even clicking the sign in button. If the token is expired or doesn’t exist then make the user sign in again.
$cordovaOauth is only there to get you the appropriate tokens. What you choose to do with them after is up to you.
Does this make sense?