I had a user of my firebase android app change their email address in google workspace according to these steps to change user email.
My app uses (only) google to sign in:
val cred = GoogleAuthProvider.getCredential(account.idToken, null)
FirebaseAuth.getInstance().signInWithCredential(cred)
After the change the user is able to sign in with their new email and my app still identifies them with the same UID, but when they sign in they still see their old profile pic and their old email which the app retrieves:
FirebaseAuth.getInstance().currentUser?.let { user ->
user.email
user.displayName
user.photoUrl
}
All of those properties still refer to the old email, old profile pic and old display name, but we are mainly concerned about the email property.
I'd like to know why we're still seeing the old email, and is this something that needs to be fixed on the application side or the admin/google workspace side?
Firebase Authentication creates a cached copy of the pertinent information from the OAuth provider when it first creates the account. This information is not updated afterwards, unless you do so yourself with the Admin SDK.
Related
I am developing an application in Flutter, which retrieves podometric data through Apple Health and Google Fit.
Apple Health is correctly configured.
Google Fit does not work.
The application asks for access to the data, it opens the pop up select an account then nothing happens, and the value returned corresponding to the access is false.
I am using the : health: ^3.0.3
I am requesting access like this:
DateTime endDate = DateTime.now();
DateTime startDate =
widget.user.lastTimeRecoverHealthData.add(Duration(seconds: 1));
HealthFactory health = HealthFactory();
List<HealthDataType> types = [
HealthDataType.STEPS,
HealthDataType.DISTANCE_WALKING_RUNNING,
];
List<HealthDataPoint> healthData;
health.requestAuthorization(types).then((value) {
print("health.requestAuthorization: THEN");
print("then return ${value}");
if (value) {
[...]
}
})
I can't find where I miss a step in the Google fit and Android process.
Any help is welcome.
You have to make sure the package name you registered to your project on Google Cloud Platform is matched with the package name from the app you are develop.
Check the OAuth 2.0 Client IDs from Credentials on your Google Cloud Console.
I ran into same problem you described and my mistake was the name from the Credentials is was not match with my app's package name.
FINALLY GOT THIS ISSUE SOLVED!!
So the problem doesn't lie in the version I am using 3.4.0 but still got the problem solved
Authorization not granted. And stuck in loading screen
Stuck in authorization request screen
When you create your OAuth 2.0 consent screen try to add at least 2 email addresses to the TEST USER section and make sure to login from that emails.
[Add 2 email addresses in Test User]2
After that make sure to verify your application from Google, it will work until you test your app once you release the application, it will not work
Verify Your Application from Google
Final Result
4
I am using Firebase in my app and one of the things that I added recently was the option to send a reset password link.
When the user receives the email it looks as follows:
Is there any option to read certain data from my Firebase firestore and display it in the email?
For example, when user1 registered to the app he needed to set an email and a username (say: user1_cool). Now, when user1 sent himself a reset link I had like it to show:
Hello user1_cool,
...
From this link, it seems impossible but still was wondering if someone found a way.
Right now my email is as follows:
<p>Hello %DISPLAY_NAME%,</p>
<p>Follow this link to reset your password for your %EMAIL% account.</p>
<p><a href='%LINK%'>%LINK%</a></p>
<p>If you didn’t ask to reset your password, you can ignore this email.</p>
<p>Thanks,</p>
<p>NeighborBook team</p>
Thank you
Well, as far as I know,
Is there any option to read certain data from my Firebase firestore
and display it in the email?
No, Currently there is no possibility of that in firebase ...
But since you mentioned about user setting a user name I am writing an alternative for this
If you want to show user name in %DISPLAY_NAME% you can modify user display name like this if you want
UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()
.setDisplayName("Custom User Name Goes Here")
.build();
This will modify user display name and when you use the same template for the email the username set by the user will be sent instead of usual display name
Note: This is recommended and should be only used in this
specific case
For more info visit : UserProfileChangeRequest.Builder
You can only change a few things about the emails that Firebase sends, as otherwise this functionality could be abused to deliver irrelevant content.
If you want full control over the emails that are sent, you'll need to implement your own email delivery. You can still use Firebase Authentication's handler for the links in that email, but following the documentation on customizing the email handler.
Let's say I have 4 apps, "Uber Clone" for iOS and Android and "Uber Driver Clone" for iOS and Android. I am using the same Firebase project for all 4 since they share the same database.
When it comes to Facebook Auth though, I can only add a single Facebook app to Firebase. And for every Facebook App I can only add a single iOS and a single Android app. Therefore how can I make this work?
Firebasers, any recommendation/solution in mind?
Multiple apps on a single Facebook app
Go to your Facebook developer console
Go to your app's page
Go to the basic settings
Add all relevant bundle IDs
Here's the key: Add a different URL Scheme suffix for each app. This differentiates each iOS app under your single Facebook App.
In each of your apps info.plist add the suffix information (Make sure both the URL scheme is updated and the "FacebookURLSchemeSuffix" is added!)
Now each of your apps is under the same Facebook App, and thus can register under the same Firebase Realtime Database. Check this out for more info: Two iOS apps using the same Facebook app ID - is it possible?
At this point in time, it does not seem possible to have multiple FB apps under a single Firebase Realtime Database.
A single Facebook App is allowed to connect to multiple iOS apps and multiple Android apps.
For iOS apps, you can specify multiple Bundle ID at Facebook App settings page.
Taken you're using Firebase for authentication, I presume you're using either Real Time Database or Cloud Firestore to store user data as well.
In your user data model, you can add user types.
For example,
user_type : "driver"
Then query users like so:
DBreference.collection("users").whereField("user_type", isEqualTo: "driver").getDocuments() {(querySnapshot, error) in
if error != nil { print(error.debugDescription)
return
}
else if let users = querySnapshot.documents {
for user in users {
guard let userType = user.data()["user_type"] as? String else { return }
print(userType)
}
}
}
This way you don't have to create multiple Facebook apps. Just use the one you have and segment users and their priviliges accordingly.
For example, upon login on both apps, do a check, whether the is user trying to log in as a driver or a passenger.
if currentUser.userType != "passenger" {
print("You can't log into the passanger app with your driver's account.")
}
Hope this helps.
We have an app available in android, ios and web. The app uses facebook login(using easyfacebook.jar) as alternate way of authorizing users. It was working fine but due to recent changes in facebook sdk I am unable to get the actual facebook id as the facebook api returns app-specific user id. From the facebook page:
Changes from v1.0 to v2.0
App-scoped User IDs: To better protect people's information, when
people log into a version of your app that has been upgraded to use
Graph API v2.0, Facebook will now issue an app-scoped ID rather than
that person's orginal ID. However, for users that have previously
logged into your app, the user ID will not change.
The id that I am getting are different for ios, web and android. Please take a look:
ios and web https://www.facebook.com/559709594 //return's actual userID
Android https://www.facebook.com/10152580446094595 //not returning actual userId
I tried the official facebook sdk to get the actual user id but it was not successful. I am trying to get user id using the following way:
user = graphApi.getMyAccountInfo();
facebookIdLogin = user.getId();
//returns app specific id not actual user id id = 10152580446094595
Log.d("username is : ", user.getName());//return actual value
Log.d("facebook id is this", facebookIdLogin);
Log.d("facebook user link", user.getLink());
//returns www.facebook.com/10152580446094595
Is there any way for me to get the actual userId. I need the actual userId because of synchronization between the platforms. Whatever I do I am only getting the app specific userId. Here's the permission I am requesting:
String permissions[] = { "public_profile", "user_friends", "email" };
Any help is highly appreciated.
What you're seeing is the difference between an app-scoped user_id which was introduced with the Graph API v2.0, and the global user_id.
Have a look at https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids for the details.
This question was just a misunderstanding. All the versions were receiving profile id different than the actual profile id. In android I had a separate dashboard configured so I was receiving different id.
Note the id will be same for the same project in the same dashboard with same account.. Hope this helps someone.
I have created sync adapter for android that syncs data with my server. I works fine, but now I want to be able to change my username and password without removing and adding the account again. How can I do this?
I have a login screen that has edit texts for entering username and password, but how to apply these changes to the account?
EDIT:
Found a way how to change the password:
AccountManager.get(mContext).setPassword(account, password );
where account is my account, and password is the new password.
So now my question is: HOW TO CHANGE THE USERNAME?
I can change the password with no problem, but if I want to change the username of the account I must delete and recreate the account with the new username. This deletes all data from that account and resyncs the account again from the beginning.
AccountManager.renameAccount(Account account, String newName, AccountManagerCallback<Account> callback, Handler handler)
This has been unfortunately added only in API 21 (documentation).
In previous versions, deleting and recreating the account with the new username is the only way, as mentioned in another answer.
Use an AccountAuthenticatorActivity, which you can either open from the Settings -> Accounts & Sync page inside your account, or when you try to fetch from the server and get an error indicating wrong login. Look here for details of how to set it up. Writing an Android Sync Provider: Part 1