remove previous logged in account in Facebook login for flutter application
I have successfully implemented the Facebook login integration with the flutter application
The Issue I am facing is once I have logged in with certain user credentials and after that I logged out.
Now when I attempt to login I am asked to use previously logged in user credentials only.
There is no other option to sign with new user credentials.
How Should I resolve it?
I am using this dependency flutter_facebook_login
for the Facebook integration
When I logged out I used facebookLogin.logOut();
and then _auth.signOut()
See also questions close to this topic
-
Consent with the User Messaging Platform Android
I used the UMP solution for the EU consent to comply with GDPR but I found out while testing if the user click on "Manage options" and "Submit" that's enough to not have any more advertisements in the app not even non-personalized ads since all checkbox of consent are disabled , and either even if I choose "consent" the consent type remains in UNKNOWN no matter what ..
I followed the exact same steps in the official documentation , is there solution to this ?
-
Automatically Adding Dependencies to App's Gradle File
I'm using Android Studio 4.1.1 and working with fragments.
I used this snippet to add a
Fragment
to a blank container in anActivity
getSupportFragmentManager().beginTransaction().setReorderingAllowed(true) .add(R.id.fragment_container_view, SenderFragment.class, null).commit();
It would not let me specify the
Fragment
has a.class
until I added this dependency to the app's gradle file: (one hour wasted!)def fragment_version = "1.2.5" implementation "androidx.fragment:fragment:$fragment_version"
Is it possible to automatically add the dependencies needed ? If not, how can we plan what dependencies are needed for a given project?
Insights and comments, most welcome
-
Updating TextView in update() function of observer activity
I'm trying to update a text view in my activity on receiving a notification from an Observable object. My code is as follows:
@Override public void update(Observable o, Object arg) { if (o == BatteryPercentageSingleton.getInstance()) { Log.e("CHANGE", "OBSERVED"); String text = "Battery percentage: " + BatteryPercentageSingleton.getInstance().getBatteryPercentage() + "%"; runOnUiThread(new Runnable() { @Override public void run() { Log.e("thread", "been called"); batteryPercentageView.setText(text); } }); } }
I am getting the output from both
log
statements but there is no change to my TextView on my UI when this is called - anyone know what I'm doing wrong here? -
Firebase "Phone Verified" missing
I'm using firebase sms verification, on success, I call my backend
/complete-signup
to do more work with the JWT token generated (that depends on user having verified their phone. not just create an account with it.)Now, as mentioned in this question, there is no
isPhoneVerified()
method...andgetPhoneNumbe()
is no help, a user can signup with their phone, skip the verify code step, and their account will still be created on firebase.Client side validation (
SharedPreferences
as mentioned in the answer) is no help, since there's no way to communicate that info securely to my backend (or is there?)..because what's preventing the user from calling my backend/complete-signup
from curl..What I'm thinking:
- add "phone verified" as custom claim from client (not possible)
- create custom token on client contaning {userId,phoneVerified} to send to my backend (super insecure!)
- get the value of the otp code sent by firebase in the backend to verify it (not possible)
- use another api (really dont want to do this)
- ??
ideas?
-
Can anyone help me with this issue of retrieving data from Firebase using swift on Xcode? "Editor placeholder in source file"
So basically I have been having an issue with an error that keeps popping up in my code when I try to get documents from Firestore. Im not really sure why, can someone please clarify it to me. I am trying to use the structure of Log and to capture the different fields in a document. After this, I want add it to an array of Logs so that I can then present in my view.
My code:
import Foundation import Firebase
This is the Log structure which I wanted to use to model my data:
struct Log { // MARK: - Properties var date : Date var leftUO : Bool var leftUI : Bool var leftLI : Bool var leftLO : Bool var rightUO : Bool var rightUI : Bool var rightLI : Bool var rightLO : Bool }
And this is the way I wanted to retrieve the data from firebase and store it locally.
struct LogsModel { let storage = Firestore.firestore() func retrieveLogs(uid: String, user : String) -> [Log] { var logs : [Log] = [] storage.collection("/LOGS" + user + uid).getDocuments { (snapshot, error) in guard let documents = snapshot?.documents else { print(error?.localizedDescription ?? "Documents not retrived") return } for document in documents { let date = document.get(Constants.FirebaseConstants.DATE) let fieldLLI = document.get(Constants.FirebaseConstants.LEFTLOWERINNER) let fieldLLO = document.get(Constants.FirebaseConstants.LEFTLOWEROUTER) let fieldLUO = document.get(Constants.FirebaseConstants.LEFTLOWEROUTER) let fieldLUI = document.get(Constants.FirebaseConstants.LEFTUPPERINNER) let fieldRLI = document.get(Constants.FirebaseConstants.RIGHTLOWERINNER) let fieldRLO = document.get(Constants.FirebaseConstants.RIGHTLOWEROUTER) let fieldRUO = document.get(Constants.FirebaseConstants.RIGHTUPPEROUTER) let fieldRUI = document.get(Constants.FirebaseConstants.RIGHTUPPERINNER) let log = Log(date: date as! Date, leftUO: fieldLUO as! Bool, leftUI: fieldLUI as! Bool, leftLI: fieldLLI as! Bool, leftLO: fieldLLO as! Bool, rightUO: fieldRUO as! Bool, rightUI: fieldRUI as! Bool, rightLI: fieldRLI as! Bool, rightLO: fieldRLO as! Bool) // TODO - extract document into Log struct and add that to logs array logs += [log] } } return logs } }
I hope I clarified my issue enough. Thanks in advance for your help I really appreciate it
-
How to query for document with array element in Firestore map?
I have Firestore document with map and array within this map:
collection/{doc}.map.array
. Each array contain boolean value. For examplearray[0]==false
,array[2]==true
.I want query if element within this array is true or false. For example I want call:
const result = await admin.firestore() .collection('collection') .where(`map.array[${element}]`, '==', true) .get()
How I can do this? I try but get error.
-
'FlatButton' is deprecated and shouldn't be used. Use TextButton instead. See the migration guide in flutter
After flutters last update I took this error message from my code which works excellent. Can you help me to solve that. Have a nice day.
-
Flutter Page Transition Package on non-named Route
With a named route this package works perfectly but have not been able to get it working for route below.
void _toResultsPage() { print('getting to results page'); Navigator.of(context) .push(MaterialPageRoute(builder: (BuildContext context) { return Scaffold();
The following is what I would like to have working with this page route but still being able to use the builder instead of creating a named route:
Navigator.push( context, PageTransition( type: PageTransitionType.bottomToTop, child: Scaffold(), );
-
Flutter : error is Looking up a deactivated widget's ancestor is unsafe
So I am trying to log in using NodeJS in my flutter app, and I am able to log in but when I try to add a circular progress indicator while waiting for backend process to finish when user taps on login button by setting state like,
setState(() { validate = true; isLoading = true; });
And then I do after successfully logging in,
setState(() { validate = true; isLoading = false; });
I am getting this error :
error is Looking up a deactivated widget's ancestor is unsafe. I/flutter ( 4699): At this point the state of the widget's element tree is no longer stable. I/flutter ( 4699): To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor
And I am unable to navigate to another screen but if I remove setState I am successfully navigating to another screen.
My code for login button click is as follows. isLoading starts with false and when its true, I show a circular progress indicator.
Future saveLogInData(BuildContext context) async { setState(() { isLoading = true; }); final formState = _logInFormKey.currentState; if (formState.validate() ) { formState.save(); try { Map<String, String> data = { "email": loginEmailController.text, "password": loginPasswordController.text, }; print("my data is : $data"); var response = await networkHandler.post("user/login", data); print("statuscode is ${response.statusCode}"); if(response.statusCode == 200 || response.statusCode == 201){ Map<String, dynamic> output = json.decode(response.body); print(output['token']); setState(() { validate = true; isLoading = false; }); Navigator.push( context, MaterialPageRoute( builder: (context) => Home( ))); } else{ String output = json.decode(response.body); print("output is ${output}"); setState(() { validate = false; isLoading = false; }); } // user.sendEmailVerification(); } catch (e) { print("error is $e}"); } finally { isLoading = false; } } else { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text("Error"), content: Text("Please check your email and password"), actions: <Widget>[ FlatButton( child: Text("Close"), onPressed: () { Navigator.of(context).pop(); }, ) ], ); }); } }
-
GitHub GraphQL API returning forbidden when using access token from GithubAuthProvider
I'm using GithubAuthProvider with the added scope
repo
to get the user's access token which is later used to access the GitHub GraphQL API (the GitHub App has the permissions for Contents and Metadata set to Read-only).The problem is when I'm trying to list private repos. The API returns an empty array as if I don't have the required permissions. Moreover, when I try to list branches of a user's repo it returns an error of type
FORBIDDEN
.Query:
query { viewer { repository(name: "some-repo") { refs(refPrefix: "refs/heads/", first: 10) { nodes { name } } } } }
Response:
{ "data": { "viewer": { "repository": { "refs": null } } }, "errors": [ { "type": "FORBIDDEN", "path": [ "viewer", "repository", "refs" ], "extensions": { "saml_failure": false }, "locations": [ { "line": 7, "column": 7 } ], "message": "Resource not accessible by integration" } ] }
What am I missing?
-
Environment variables disappear when Firebase hosted (React) site is accessed
Sometimes, when I visit my web app, I get the following error in the console:
a: null code: "auth/invalid-api-key" message: "Your API key is invalid, please check you have copied it correctly."
Other times I don't have a problem and the app works fine. The problem seems to be to do with my environment variables, saved in my .env file. I've console.log'd them and most of them appear to have disappear whenever I get the above error. They are present at other times.
I'm running a hosted (React) Firebase app and using the Firebase Auth on a back-end node.js server hosted on Heroku.
-
Facebook Authentication Page never show in Xamarin.Forms app when following Microsoft's guide on authenticating users with Azure Cosmos DB and Xamarin
I am following this guide: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/data-cloud/authentication/azure-cosmosdb-auth
I successfully deployed the web app and created the Azure Cosmos DB according to the guide by using the GitHub sample code found here: https://github.com/xamarin/xamarin-forms-samples/tree/master/WebServices/TodoDocumentDBAuth
However, when opening my Xamarin.Forms app and when the LoginAsync() method is invoked (https://github.com/xamarin/xamarin-forms-samples/blob/master/WebServices/TodoDocumentDBAuth/Xamarin.Forms/TodoDocumentDB/Services/DocumentDBService.cs) the Completed event (or my additionally added Error event) is never triggered and no Facebook Login page is shown in the Xamarin.Forms application.
Although, if I copy paste the link from WebRedirectAuthenticator-instance
(Constants.ResourceTokenBrokerUrl + "/.auth/login/facebook")
and paste it in my browser it works fine.Everything seems to work fine, except that no Facebook Authentication Page is shown. How come the Facebook Authentication page is not shown in my Xamarin application?
-
Trying to connect using FacebookAuthProvider from Firebase but get error. react native
I'm trying to connect new users through Facebook authentication and Firebase SDK with createContext, but I'm getting:
new FacebookAuthProvider()
is not supported on the native Firebase SDKs.I'm using the firebase doc here : https://firebase.google.com/docs/auth/web/facebook-login and here : https://github.com/firebase/snippets-web/blob/1452a031ee1b7904a361b23391af8533237eab82/auth/facebook.js#L9-L9
My code :
import React, {createContext, useState} from 'react'; import auth from '@react-native-firebase/auth'; import firebase from '@react-native-firebase/app'; export const AuthContext = createContext({}); export const AuthProvider = ({children}) => { const [user, setUser] = useState(null); return ( <AuthContext.Provider value={{ user, setUser, login: async (email, password) => { try { await auth().signInWithEmailAndPassword(email, password); } catch (e) { return handleError(e); } }, register: async (email, password) => { try { await auth().createUserWithEmailAndPassword(email, password); } catch (e) { return handleError(e); } }, logout: async () => { try { await auth().signOut(); } catch (e) { return handleError(e); } }, loginWithFacebook: async (processRequest) => { try { let provider = new firebase.auth.FacebookAuthProvider(); provider.addScope('user_birthday'); provider.setCustomParameters({ display: 'popup', }); await firebase.auth().signInWithPopup(provider); } catch (e) { console.log(e); } }, }}> {children} </AuthContext.Provider> ); };
If someone have another idea for using facebook connection with firebase SDK and useContext I'm okay too.
-
Facebook Login and Firebase Android Studio doesn't work (Kotlin)
I'm completely stuck with the Login Activity, I can't make it fully work with firebase... The facebook login by itself I managed to work, but with firebase it doesn't.
I'm using an activity sequence that looks like (Splash > LoginActivity > MainActivity (tabs)), so I ask please, be specific about the activity and layout, cause I can easily get loss within the codes hehe, no surprise I'm not an expert, treat me like I'm stupid cause I am.
If there's a better way to make it work, please save me.
import android.content.Intent import android.os.Bundle import android.os.PersistableBundle import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.facebook.AccessToken import com.facebook.CallbackManager import com.facebook.FacebookCallback import com.facebook.FacebookException import com.facebook.login.LoginResult import com.google.firebase.auth.FacebookAuthProvider import com.google.firebase.auth.FirebaseAuth import kotlinx.android.synthetic.main.activity_login.* import org.jetbrains.anko.startActivity class LoginActivity : AppCompatActivity() { var firebaseAuth:FirebaseAuth?=null var callbackManager:CallbackManager?=null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) firebaseAuth = FirebaseAuth.getInstance() callbackManager = CallbackManager.Factory.create() facebookLoginButton.setReadPermissions("email") facebookLoginButton.setOnClickListener{ signIn() } } private fun signIn() { facebookLoginButton.registerCallback(callbackManager,object:FacebookCallback<LoginResult>{ override fun onSuccess(result: LoginResult?) { handleFacebookAccessToken(result!!.accessToken) val successLogin = Intent(this@LoginActivity, MainActivity::class.java) startActivity(successLogin) } override fun onCancel() { } override fun onError(error: FacebookException?){ } }) } private fun handleFacebookAccessToken(accessToken: AccessToken?) { //get credential val credential = FacebookAuthProvider.getCredential(accessToken!!.token) firebaseAuth!!.signInWithCredential(credential) .addOnFailureListener{ e-> Toast.makeText(this,e.message,Toast.LENGTH_LONG).show() } .addOnSuccessListener { result -> //Get Email val email = result.user?.email Toast.makeText(this,"Logged in : "+email,Toast.LENGTH_LONG).show() } } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) callbackManager!!.onActivityResult(requestCode,requestCode,data) } }