I am using firebase for chat in my application.
When i use setValue method to write at a node by Using childByAutoId it works fine.
But when my AuthToken expires and I Authenticate the user again with my custom token, the message is saved on Firebase but My .ChildAdded Observer fails to observe this change.
I am using Authenticate Using custom token method for Firebase.
Related
My usecase is when user logout need to avoid sending notifications (deleteToken user). and when he again loggedin need to send the notifiations (need to generate new device fcm token).
After calling deleteToken method, and calling getToken returns previous one, not newer.
I am building a mobile app with Flutter and Flask Backend. For authentication, we allow username/password and google oath2 but will delegate to Firebase for credential validation.
So users credentials are stored on Firebase project but problem is we have a seperate Database with account table (we use a firebase_uuid field in account table to map to user on firebase project)
I am not sure of the registration flow since we need to handle both databases
For user/password registation, should Flutter app or Backend communicate to Firebase to create account?
I think backend should do it since after creating account on Firebase, we also need to create account on our own DB?
If we let flutter send request to Firebase directly to create account, what would be the correct flow so that my backend can also save user info in our BE database?
For google oath2 registration, similarly, if we were to do it on Flutter, what would be the flow to populate in our BE database?
Similarly, what is the flow in case of login and changing user's password?
Its pretty simple if we do not have Backend at all and just use firebase as backend but other operations required a seperate BE service
I'm currently using Firebase cloud functions as my mobile app's backend and I'm using Auth0 as my authentication provider.
My problem is that I've used Postman to send test login requests to my API and I'm able to get a valid JWT. I then deleted the user account through Auth0's user management panel and used Postman to test the login function again to see the type of response I would receive. Instead of receiving any errors, I receive a new valid JWT which allows me to access protected routes even though the user does not exist.
I've tried setting the response cache control to "no-store" and yet I'm able to receive a valid JWT. What could the reason be?
When a client signs in with Github, I would like to trigger a Cloud Function that retrieves the user's profile data from Github and stores it in /users/{uid}/profile in the Realtime database.
I can trigger my cloud function when a new user signs up using:
exports.fetchProfile = functions.auth.user().onCreate(event => {
// user = event.data
// uid = user.uid
// access_token = ???
// todo: request user profile from Github using access_token
// todo: save profile in /users/{uid}/profile
});
But, how do I obtain the user's access_token needed for making the Github profile request? Thanks.
What I have tried:
On the client, use FirebaseAuth to get the Github access_token.
Create a Firebase credential using the access_token from (1).
Sign in with the credential from (2), I get a FIRUser in success callback, from which I can obtain uid.
I write {uid: access_token} to a queue in the Realtime database, this in turn triggers my cloud function that does the profile retrieval.
All these just to get the user's access_token, can I do better?
You can't do it with the user creation trigger.
You have multiple options:
after sign up, get the access token from the client and saved it in the real-time database under a location accessible by the specified user. You can then set a cloud functions database trigger for that location. When that is triggered, you get the access token and make your API call to GitHub and get the data and do whatever you want with it.
Run everything on the client side. Since you have the access token after sign up in the client (browser), make the API call to GitHub and then save the profile data in a database location accessible by the user only. You can add a cloud function to trigger on changes to that location if you need to run additional admin operations.
By the way, Firebase Auth (4.0.0) now returns additional user data. Check: https://firebase.google.com/docs/reference/js/firebase.auth#.UserCredential
You can get the additional data by calling result.additionalUserInfo.profile, or the GitHub username: result.additionalUserInfo.username.
I'm trying to implement Facebook Login with AWS Cognito.
After receiving the access token from Facebook, I'm not able to update the credentials provider.
let token = FBSDKAccessToken.currentAccessToken().tokenString
credentialsProvider.logins = [AWSCognitoLoginProviderKey.Facebook.rawValue: token]
After this, if I print [AWSCognitoLoginProviderKey.Facebook.rawValue: token] I get the long string but if I print credentialsProvider.logins I get NIL.
As a result, my identity pool always shows the user as unauthenticated even after logging in with Facebook.
Any help would be appreciated.
Thanks!!
Are you using the latest AWS iOS SDK? If yes, then credentialProvider.logins will always be NIL and will cause your app to create unauthenticated identities.
We are in process of updating our documentation for this but essentially this is what you need to do.
Use this constructor to create the credentials provider. The identityProviderManager here should be an implementation of AWSIdentityProviderManager Protocol and the logins method should return the dictionary mapping for your provider name to the token. The credentials provider will call this method every time it needs the identity provider token.