@@ -35,6 +35,17 @@ admin.auth().getUserByPhoneNumber(phoneNumber)
3535 } ) ;
3636// [END get_user_by_phone]
3737
38+ // [START get_user_by_federated_id]
39+ admin . auth ( ) . getUserByProviderUid ( 'google.com' , 'google_uid1234' )
40+ . then ( function ( userRecord ) {
41+ // See the UserRecord reference doc for the contents of userRecord.
42+ console . log ( 'Successfully fetched user data:' , userRecord . toJSON ( ) ) ;
43+ } )
44+ . catch ( function ( error ) {
45+ console . log ( 'Error fetching user data:' , error ) ;
46+ } ) ;
47+ // [END get_user_by_federated_id]
48+
3849// [START bulk_get_users]
3950admin . auth ( ) . getUsers ( [
4051 { uid : 'uid1' } ,
@@ -111,6 +122,37 @@ admin.auth().updateUser(uid, {
111122 } ) ;
112123// [END update_user]
113124
125+ // [START update_user_link_federated]
126+ // Link the user with a federated identity provider (like Google).
127+ admin . auth ( ) . updateUser ( uid , {
128+ providerToLink : {
129+ uid : 'google_uid12345' ,
130+ providerId : 'google.com'
131+ }
132+ } )
133+ . then ( function ( userRecord ) {
134+ // See the UserRecord reference doc for the contents of userRecord.
135+ console . log ( 'Successfully updated user' , userRecord . toJSON ( ) ) ;
136+ } )
137+ . catch ( function ( error ) {
138+ console . log ( 'Error updating user:' , error ) ;
139+ } ) ;
140+ // [END update_user_link_federated]
141+
142+ // [START update_user_unlink_federated]
143+ // Unlink the user from a federated identity provider (like Google).
144+ admin . auth ( ) . updateUser ( uid , {
145+ providersToDelete : [ 'google.com' ]
146+ } )
147+ . then ( function ( userRecord ) {
148+ // See the UserRecord reference doc for the contents of userRecord.
149+ console . log ( 'Successfully updated user' , userRecord . toJSON ( ) ) ;
150+ } )
151+ . catch ( function ( error ) {
152+ console . log ( 'Error updating user:' , error ) ;
153+ } ) ;
154+ // [END update_user_unlink_federated]
155+
114156// [START delete_user]
115157admin . auth ( ) . deleteUser ( uid )
116158 . then ( function ( ) {
0 commit comments