| Title: | R Wrapper for 'Firebase Authentication REST API' |
|---|---|
| Description: | A convenient and user-friendly interface to interact with the 'Firebase Authentication REST API': <https://firebase.google.com/docs/reference/rest/auth>. It enables R developers to integrate 'Firebase Authentication' services seamlessly into their projects, allowing for user authentication, account management, and other authentication-related tasks. |
| Authors: | Kennedy Mwavu [aut, cre, cph] (Maintainer/developer of firebase.auth.rest since 2024, ORCID: <https://orcid.org/0009-0006-3157-7234>) |
| Maintainer: | Kennedy Mwavu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.1 |
| Built: | 2026-05-14 07:08:35 UTC |
| Source: | https://github.com/kennedymwavu/firebase.auth.rest |
Change email
change_email(id_token, email)change_email(id_token, email)
id_token |
String. A Firebase Auth ID token for the user. |
email |
String. User's new email. |
DISCLAIMER: Changing a users's email requires that you disable email enumeration protection for your firebase project. This is NOT recommended.
Learn about email enumeration protection
Visit Firebase Auth REST API docs for more details
A named list with the following items:
localId: The uid of the current user.
email: User's email address.
passwordHash: Hash version of password.
providerUserInfo: A named list of of all linked provider objects which
contain "providerId" and "federatedId".
idToken: New Firebase Auth ID token for user.
refreshToken: A Firebase Auth refresh token.
expiresIn: string The number of seconds in which the ID token expires.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: # first sign in user and get the 'id_token': user <- sign_in(email = "[email protected]", password = "password") id_token <- user$idToken # change email: response <- change_email( id_token = id_token, email = "[email protected]" ) response ## End(Not run)## Not run: # first sign in user and get the 'id_token': user <- sign_in(email = "[email protected]", password = "password") id_token <- user$idToken # change email: response <- change_email( id_token = id_token, email = "[email protected]" ) response ## End(Not run)
Change password
change_password(id_token, password)change_password(id_token, password)
id_token |
A Firebase Auth ID token for the user. |
password |
User's new password. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
localId: The uid of the current user.
email: User's email address.
passwordHash: Hash version of password.
providerUserInfo: A named list of of all linked provider objects which
contain "providerId" and "federatedId".
idToken: New Firebase Auth ID token for user.
refreshToken: A Firebase Auth refresh token.
expiresIn: string The number of seconds in which the ID token expires.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: # first sign in user and get the 'id_token': user <- sign_in(email = "[email protected]", password = "password") id_token <- user$idToken # change password: response <- change_password( id_token = id_token, password = "new-user-password" ) response ## End(Not run)## Not run: # first sign in user and get the 'id_token': user <- sign_in(email = "[email protected]", password = "password") id_token <- user$idToken # change password: response <- change_password( id_token = id_token, password = "new-user-password" ) response ## End(Not run)
Delete account
delete_account(id_token)delete_account(id_token)
id_token |
The Firebase ID token of the user to delete. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: # first sign in user and get the 'id_token': user <- sign_in(email = "[email protected]", password = "password") id_token <- user$idToken # delete user account: response <- delete_account(id_token = id_token) response ## End(Not run)## Not run: # first sign in user and get the 'id_token': user <- sign_in(email = "[email protected]", password = "password") id_token <- user$idToken # delete user account: response <- delete_account(id_token = id_token) response ## End(Not run)
Exchanges a custom Auth token for an ID and refresh token
exchange_custom_token(token)exchange_custom_token(token)
token |
String. A Firebase Auth custom token from which to create an ID and refresh token pair |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
idToken: A Firebase Auth ID token generated from the provided custom token.
refreshToken: A Firebase Auth refresh token generated from the provided custom token.
expiresIn: The number of seconds in which the ID token expires.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: exchange_custom_token(token = "your-firebase-auth-custom-token") ## End(Not run)## Not run: exchange_custom_token(token = "your-firebase-auth-custom-token") ## End(Not run)
Refreshes a Firebase ID token
exchange_refresh_token(refresh_token)exchange_refresh_token(refresh_token)
refresh_token |
String. A Firebase Auth refresh token. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
expires_in: The number of seconds in which the ID token expires.
token_type: The type of the refresh token, always "Bearer".
refresh_token: The Firebase Auth refresh token provided, or a new
refresh token.
id_token: A Firebase Auth ID token.
user_id: The uid corresponding to the provided ID token.
project_id: Your Firebase project ID.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: # first sign in user and get the 'refresh_token': user <- sign_in(email = "[email protected]", password = "password") refresh_token <- user$refreshToken # exchange the refresh token: response <- exchange_refresh_token(refresh_token = refresh_token) response ## End(Not run)## Not run: # first sign in user and get the 'refresh_token': user <- sign_in(email = "[email protected]", password = "password") refresh_token <- user$refreshToken # exchange the refresh token: response <- exchange_refresh_token(refresh_token = refresh_token) response ## End(Not run)
Get user data from firebase
get_user_data(id_token)get_user_data(id_token)
id_token |
String. The Firebase ID token of the account. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
users: A list of length 1 which contains a nested named list with the
following items:
localId: The uid of the current user.
email: The email of the account.
emailVerified: Whether or not the account's email has been verified.
displayName: The display name for the account.
providerUserInfo: Named list of provider objects which contain
"providerId" and "federatedId".
photoUrl: The photo Url for the account.
passwordHash: Hash version of password.
passwordUpdatedAt: The timestamp, in milliseconds, that the account
password was last changed.
validSince: The timestamp, in milliseconds, which marks a boundary,
before which Firebase ID token are considered revoked.
disabled: Whether the account is disabled or not.
lastLoginAt: The timestamp, in milliseconds, that the account last
logged in at.
createdAt: The timestamp, in milliseconds, that the account was
created at.
customAuth: Whether the account is authenticated by the developer.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: user_data <- get_user_data("<id_token>") lapply(user_data, `[[`, 1) ## End(Not run)## Not run: user_data <- get_user_data("<id_token>") lapply(user_data, `[[`, 1) ## End(Not run)
Send email verification
send_email_verification(id_token)send_email_verification(id_token)
id_token |
The Firebase ID token of the user to verify. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
email: The email of the account.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: send_email_verification("id-token-goes-here") ## End(Not run)## Not run: send_email_verification("id-token-goes-here") ## End(Not run)
Send password reset email
send_password_reset_email(email)send_password_reset_email(email)
email |
User's email address. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
email: Users' email address.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: send_password_reset_email("user-email-goes-here") ## End(Not run)## Not run: send_password_reset_email("user-email-goes-here") ## End(Not run)
Sign in a user with email & password
sign_in(email, password)sign_in(email, password)
email |
User email |
password |
User password |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
idToken: A Firebase Auth ID token for the authenticated user.
email: The email for the authenticated user.
refreshToken: A Firebase Auth refresh token for the authenticated user.
expiresIn: The number of seconds in which the ID token expires.
localId: The uid of the authenticated user.
registered: Whether the email is for an existing account.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: sign_in(email = "user-email", password = "strong-password") ## End(Not run)## Not run: sign_in(email = "user-email", password = "strong-password") ## End(Not run)
Sign in a user anonymously
sign_in_anonymously()sign_in_anonymously()
To use sign in users anonymously, you must first enable the Anonymous sign in method in your firebase project.
Go to Firebase console and check your Sign-in providers under the Sign-in Methods tab in the Authentication service and make sure Anonymous is enabled.
Visit Firebase Auth REST API docs for more details.
A named list with the following items:
idToken: A Firebase Auth ID token for the newly created user.
email: Since the user is anonymous, this should be empty.
refreshToken: A Firebase Auth refresh token for the newly created user.
expiresIn: The number of seconds in which the ID token expires.
localId: The uid of the newly created user.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: user <- sign_in_anonymously() user ## End(Not run)## Not run: user <- sign_in_anonymously() user ## End(Not run)
Sign up with email/password
sign_up(email, password)sign_up(email, password)
email |
The email for the user to create. |
password |
The password for the user to create. |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
idToken: A Firebase Auth ID token for the newly created user.
email: The email for the newly created user.
refreshToken: A Firebase Auth refresh token for the newly created user.
expiresIn: The number of seconds in which the ID token expires.
localId: The uid of the newly created user.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: sign_up(email = "new-user-email", password = "strong-password") ## End(Not run)## Not run: sign_up(email = "new-user-email", password = "strong-password") ## End(Not run)
Update a user's profile (display name / photo URL).
update_profile( id_token, display_name = NULL, photo_url = NULL, delete_attribute = NULL )update_profile( id_token, display_name = NULL, photo_url = NULL, delete_attribute = NULL )
id_token |
String. A Firebase Auth ID token for the user. |
display_name |
String. User's new display name. Defaults to |
photo_url |
String. User's new photo url. Defaults to |
delete_attribute |
Character vector of attributes to delete.
Either "DISPLAY_NAME" or "PHOTO_URL". This will nullify these values.
Defaults to |
Visit Firebase Auth REST API docs for more details
A named list with the following items:
localId: The uid of the current user.
email: User's email address.
displayName: User's new display name.
photoUrl: User's new photo url.
passwordHash: Hash version of password.
providerUserInfo: A named list of of all linked provider objects which
contain "providerId" and "federatedId".
idToken: New Firebase Auth ID token for user.
refreshToken: A Firebase Auth refresh token.
expiresIn: string The number of seconds in which the ID token expires.
error:
NULL if no error code in response
A list of 2 if response was an error:
code: Error code
message: Error message
## Not run: update_profile( id_token = "id-token-goes-here", display_name = "new-user-display-name", photo_url = "url-to-user-photo" ) # to delete the display name attribute: update_profile( delete_attribute = "DISPLAY_NAME" ) ## End(Not run)## Not run: update_profile( id_token = "id-token-goes-here", display_name = "new-user-display-name", photo_url = "url-to-user-photo" ) # to delete the display name attribute: update_profile( delete_attribute = "DISPLAY_NAME" ) ## End(Not run)