| Title: | Connect to 'Google Firebase' |
| Version: | 2.0.2 |
| Description: | Provides an interface to 'Google Firebase' services https://firebase.google.com/, including 'Firebase Realtime Database', 'Cloud Firestore', 'Firebase Authentication', and 'Cloud Storage for Firebase'. Supports interactive use and 'shiny' applications as well as automated server-side workflows. Data frames and objects can be stored and retrieved, users can be authenticated, and files can be managed through the services' application programming interfaces. |
| Depends: | R (≥ 4.1.0) |
| License: | MIT + file LICENSE |
| URL: | https://github.com/Kohze/fireData |
| BugReports: | https://github.com/Kohze/fireData/issues |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| Imports: | httr (≥ 1.4.0), jsonlite (≥ 1.8.0), curl (≥ 5.0.0), R6 (≥ 2.5.0), openssl (≥ 2.0.0), yaml (≥ 2.3.0) |
| Suggests: | testthat (≥ 3.2.0), shiny (≥ 1.7.0), shinyjs, knitr, rmarkdown |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-09-19 17:49:41 UTC; robin |
| Author: | Robin Gounder |
| Maintainer: | Robin Gounder <robin@gounder.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-29 14:20:24 UTC |
fireData: Connect to 'Google Firebase'
Description
Provides an interface to 'Google Firebase' services https://firebase.google.com/, including 'Firebase Realtime Database', 'Cloud Firestore', 'Firebase Authentication', and 'Cloud Storage for Firebase'. Supports interactive use and 'shiny' applications as well as automated server-side workflows. Data frames and objects can be stored and retrieved, users can be authenticated, and files can be managed through the services' application programming interfaces.
The fireData package provides access to common operations in selected Google Firebase services from R, including Realtime Database, Authentication, Cloud Storage, Cloud Firestore, and Shiny integration.
Main Functions
Connection:
-
firebase_connect()- Create a Firebase connection object -
firebase_config_set()- Set configuration for the session -
firebase_config_wizard()- Interactive configuration setup
Authentication:
-
auth_sign_in()- Sign in with email/password -
auth_anonymous()- Sign in anonymously -
auth_create_user()- Create new user account -
auth_reset_password()- Send password reset email -
auth_google()- Sign in with Google OAuth
Realtime Database:
-
rtdb_get()- Read data from database -
rtdb_set()- Write data (overwrite) -
rtdb_push()- Add data with auto-generated key -
rtdb_update()- Update specific fields -
rtdb_delete()- Delete data -
rtdb_query()- Query with filtering and sorting -
rtdb_backup()- Backup entire database
Cloud Storage:
-
storage_upload()- Upload file to storage -
storage_download()- Download file from storage -
storage_delete()- Delete file from storage -
storage_list()- List files in bucket -
storage_get_url()- Get download URL
Getting Started
Set up a Firebase project at https://console.firebase.google.com
Get your project's API key from Project Settings > General
Get your database URL from Realtime Database
# Option 1: Set environment variables
Sys.setenv(FIREBASE_PROJECT_ID = "my-project")
Sys.setenv(FIREBASE_API_KEY = "AIzaSy...")
# Option 2: Use the configuration wizard
if (interactive()) {
firebase_config_wizard()
}
# Create connection and start using Firebase
conn <- firebase_connect()
rtdb_push(conn, "messages", list(text = "Hello from R!"))
Migration from v1.x
Version 2.0.2 uses the modern API introduced in the 2.x series, with consistent naming. The old functions are deprecated but still work:
| Old (v1.x) | New (v2.0.2) |
auth() | auth_sign_in() |
upload() | rtdb_push() |
download() | rtdb_get() |
put() | rtdb_set() |
patch() | rtdb_update() |
delete() | rtdb_delete() |
upload_storage() | storage_upload()
|
Configuration
fireData looks for configuration in this order:
Function arguments
Session configuration (via
firebase_config_set())Environment variables (FIREBASE_PROJECT_ID, FIREBASE_API_KEY, etc.)
Config file (~/.firedata/config.yml)
Service Account Authentication
For server-side and automated workflows, use a service account:
# Set path to service account JSON Sys.setenv(GOOGLE_APPLICATION_CREDENTIALS = "/path/to/service-account.json") # Or pass directly to connection conn <- firebase_connect(credentials = "service-account.json")
Author(s)
Maintainer: Robin Gounder robin@gounder.com (ORCID)
Authors:
Paul Spende
Other contributors:
Kevin McGinley [contributor]
See Also
Useful links:
String concatenation operator
Description
String concatenation operator
Usage
a %+% b
Arguments
a |
First string |
b |
Second string |
Value
Concatenated string
Package Startup Message
Description
Package Startup Message
Usage
.onAttach(libname, pkgname)
Package Load Hook
Description
Package Load Hook
Usage
.onLoad(libname, pkgname)
Environment Variable Names
Description
Environment Variable Names
Usage
ENV_VARS
Format
An object of class list of length 8.
Firebase Token Class
Description
Represents an authenticated Firebase token with automatic refresh capability.
Public fields
id_tokenFirebase ID token (JWT)
refresh_tokenRefresh token for obtaining new ID tokens
local_idUser's local ID (UID)
emailUser's email (if available)
expires_atPOSIXct timestamp when the token expires
api_keyFirebase API key (needed for refresh) Create a new FirebaseToken
Methods
Public methods
Method new()
Usage
FirebaseToken$new(auth_response, api_key = NULL)
Arguments
auth_responseResponse from Firebase auth API
api_keyFirebase API key for token refresh
Returns
A new FirebaseToken object Check if token is expired
Method is_expired()
Usage
FirebaseToken$is_expired(buffer_seconds = 300)
Arguments
buffer_secondsSeconds before actual expiry to consider expired
Returns
TRUE if token is expired or will expire within buffer Refresh the token if expired
Method refresh()
Usage
FirebaseToken$refresh(force = FALSE)
Arguments
forceForce refresh even if not expired
Returns
Self (invisibly) Get the current valid token
Automatically refreshes if expired.
Method get_token()
Usage
FirebaseToken$get_token()
Returns
The ID token string Print token summary
Method print()
Usage
FirebaseToken$print(...)
Arguments
...Ignored
Method clone()
The objects of this class are cloneable with this method.
Usage
FirebaseToken$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Service Account Credentials
Description
Represents credentials from a Google service account.
Public fields
project_idGCP project ID from service account
client_emailService account email address
private_keyRSA private key for signing JWTs
access_tokenCurrent OAuth access token
token_expires_atAccess token expiration time
token_cacheAccess tokens cached by their requested OAuth scopes Create from service account JSON file
Methods
Public methods
Method new()
Usage
ServiceAccountCredentials$new(path = NULL)
Arguments
pathPath to service account JSON file
Returns
A new ServiceAccountCredentials object Get an access token
Method get_access_token()
Usage
ServiceAccountCredentials$get_access_token(
scopes = c("https://www.googleapis.com/auth/firebase.database",
"https://www.googleapis.com/auth/datastore",
"https://www.googleapis.com/auth/devstorage.read_write")
)Arguments
scopesOAuth2 scopes to request
Returns
Access token string Create a signed JWT
Method create_jwt()
Usage
ServiceAccountCredentials$create_jwt(scopes, lifetime = 3600)
Arguments
scopesOAuth2 scopes
lifetimeToken lifetime in seconds
Returns
Signed JWT string
Method print()
Usage
ServiceAccountCredentials$print(...)
Arguments
...Ignored
Method clone()
The objects of this class are cloneable with this method.
Usage
ServiceAccountCredentials$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Anonymous Login (Legacy)
Description
Legacy anonymous login. Use auth_anonymous() instead.
Usage
anonymous_login(project_api)
Arguments
project_api |
The Firebase Project API key |
Value
Authentication response
User Authentication (Legacy)
Description
Legacy authentication function. Use auth_sign_in() instead.
Usage
auth(projectAPI, email = "prompt", password = "prompt")
Arguments
projectAPI |
The Firebase Project API key |
email |
User email |
password |
User password |
Value
Authentication response
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
auth(projectAPI = "AIzaSy...", email = "user@example.com", password = "password")
}
Sign In Anonymously
Description
Signs in a user anonymously. Anonymous users can be upgraded to full accounts later by linking credentials.
Usage
auth_anonymous(conn = NULL, api_key = NULL)
Arguments
conn |
Firebase connection object (or NULL to use config) |
api_key |
Firebase API key (used if conn is NULL) |
Value
Authentication response containing idToken, refreshToken, and localId
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "AIzaSy...")
result <- auth_anonymous(conn)
}
Create User Account
Description
Creates a new user account with email and password.
Usage
auth_create_user(conn = NULL, email = NULL, password = NULL, api_key = NULL)
Arguments
conn |
Firebase connection object (or NULL to use config) |
email |
User email address |
password |
User password (min 6 characters) |
api_key |
Firebase API key (used if conn is NULL) |
Value
Registration response containing idToken, email, refreshToken, expiresIn, and localId
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "AIzaSy...")
result <- auth_create_user(conn, "newuser@example.com", "password123")
}
Delete User Account
Description
Deletes the authenticated user's account.
Usage
auth_delete_user(conn = NULL, id_token = NULL, api_key = NULL)
Arguments
conn |
Firebase connection object with valid token |
id_token |
ID token (used if conn doesn't have token) |
api_key |
Firebase API key |
Value
Empty response on success
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
auth_delete_user(conn)
}
Get Current User Data
Description
Retrieves account info for the currently authenticated user.
Usage
auth_get_user(conn = NULL, id_token = NULL, api_key = NULL)
Arguments
conn |
Firebase connection object with valid token |
id_token |
ID token (used if conn doesn't have token) |
api_key |
Firebase API key |
Value
User account information
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
user_info <- auth_get_user(conn)
}
Sign In with Google
Description
Initiates Google OAuth flow and signs in to Firebase.
Usage
auth_google(
conn = NULL,
client_id = NULL,
client_secret = NULL,
request_uri,
redirect_uri = httr::oauth_callback(),
return_idp_credential = TRUE,
cache = FALSE,
api_key = NULL
)
Arguments
conn |
Firebase connection object (or NULL to use config) |
client_id |
Google OAuth client ID |
client_secret |
Google OAuth client secret |
request_uri |
Request URI for OAuth callback |
redirect_uri |
Redirect URI (defaults to httr callback) |
return_idp_credential |
Whether to return OAuth credentials |
cache |
Whether to cache the OAuth token |
api_key |
Firebase API key |
Value
Authentication response
Examples
if (interactive()) {
# Requires a configured Firebase project and OAuth client credentials.
result <- auth_google(
conn,
client_id = "your-client-id.apps.googleusercontent.com",
client_secret = "your-secret",
request_uri = "http://localhost"
)
}
Sign In with OAuth Credentials
Description
Signs in a user with OAuth credentials from a third-party provider.
Usage
auth_oauth(
conn = NULL,
request_uri,
post_body,
return_idp_credential = TRUE,
api_key = NULL
)
Arguments
conn |
Firebase connection object (or NULL to use config) |
request_uri |
The URI to which the IDP redirects the user back |
post_body |
OAuth credential (ID token or access token) and provider ID |
return_idp_credential |
Whether to return the OAuth credential |
api_key |
Firebase API key |
Value
Authentication response
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# After obtaining OAuth token from provider
post_body <- "id_token=<google_id_token>&providerId=google.com"
result <- auth_oauth(conn, "http://localhost", post_body)
}
Refresh Authentication Token
Description
Refreshes an expired ID token using a refresh token.
Usage
auth_refresh_token(conn = NULL, refresh_token, api_key = NULL)
Arguments
conn |
Firebase connection object (or NULL to use config) |
refresh_token |
The refresh token from initial authentication |
api_key |
Firebase API key (used if conn is NULL) |
Value
Response containing new id_token, refresh_token, expires_in, token_type, and user_id
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# Refresh using stored refresh token
new_tokens <- auth_refresh_token(conn, old_refresh_token)
}
Send Password Reset Email
Description
Sends a password reset email to the specified address.
Usage
auth_reset_password(conn = NULL, email, api_key = NULL)
Arguments
conn |
Firebase connection object (or NULL to use config) |
email |
User email address |
api_key |
Firebase API key (used if conn is NULL) |
Value
Response indicating success
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
auth_reset_password(conn, "user@example.com")
}
Sign In with Email and Password
Description
Authenticates a user with email and password credentials.
Usage
auth_sign_in(conn = NULL, email = NULL, password = NULL, api_key = NULL)
Arguments
conn |
Firebase connection object (or NULL to use config) |
email |
User email address |
password |
User password |
api_key |
Firebase API key (used if conn is NULL) |
Value
Authentication response containing idToken, refreshToken, localId, email, and expiresIn
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# With connection object
conn <- firebase_connect(project_id = "my-project", api_key = "AIzaSy...")
result <- auth_sign_in(conn, "user@example.com", "password123")
# Update connection with token
conn <- firebase_set_token(conn, result)
# Without connection (uses config/environment)
result <- auth_sign_in(email = "user@example.com", password = "password123")
}
Update User Profile
Description
Updates the display name and/or photo URL of the authenticated user.
Usage
auth_update_profile(
conn = NULL,
display_name = NULL,
photo_url = NULL,
id_token = NULL,
api_key = NULL
)
Arguments
conn |
Firebase connection object with valid token |
display_name |
New display name (or NULL to keep current) |
photo_url |
New photo URL (or NULL to keep current) |
id_token |
ID token (used if conn doesn't have token) |
api_key |
Firebase API key |
Value
Updated user data
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
auth_update_profile(conn, display_name = "John Doe")
}
Base64URL Encode
Description
Base64URL Encode
Usage
base64url_encode(data)
Arguments
data |
Raw bytes or string to encode |
Value
Base64URL encoded string
Build Authentication API URL
Description
Build Authentication API URL
Usage
build_auth_url(endpoint, api_key)
Arguments
endpoint |
Auth endpoint (e.g., "accounts:signInWithPassword") |
api_key |
Firebase API key |
Value
Complete URL for the auth endpoint
Build Firestore Collection URL
Description
Build Firestore Collection URL
Usage
build_firestore_collection_url(project_id, collection)
Build Firestore Document URL
Description
Build Firestore Document URL
Usage
build_firestore_document_url(project_id, collection, document)
Build Firebase Firestore URL
Description
Build Firebase Firestore URL
Usage
build_firestore_url(project_id)
Arguments
project_id |
Firebase project ID |
Value
The Firestore base URL
Build Realtime Database Path URL
Description
Build Realtime Database Path URL
Usage
build_rtdb_path_url(base_url, path)
Arguments
base_url |
Database base URL |
path |
Database path |
Value
Complete URL with .json suffix
Build Firebase Realtime Database URL
Description
Build Firebase Realtime Database URL
Usage
build_rtdb_url(project_id = NULL, database_url = NULL)
Arguments
project_id |
Firebase project ID |
database_url |
Exact database URL (recommended for regional databases) |
Value
The database base URL
Build a Cloud Storage Media Upload URL
Description
Build a Cloud Storage Media Upload URL
Usage
build_storage_upload_url(bucket, object, predefined_acl = NULL)
Arguments
bucket |
Storage bucket name |
object |
Object path |
predefined_acl |
Optional predefined object ACL. Leave NULL for buckets that use uniform bucket-level access. |
Value
Complete media upload URL
Build Storage API URL
Description
Build Storage API URL
Usage
build_storage_url(bucket, object = NULL, upload = FALSE)
Arguments
bucket |
Bucket name |
object |
Object path (optional) |
upload |
Whether this is an upload URL |
Value
Complete storage URL
Build Token Refresh URL
Description
Build Token Refresh URL
Usage
build_token_url(api_key)
Arguments
api_key |
Firebase API key |
Value
Complete URL for token refresh
Calculate Exponential Backoff Delay
Description
Calculate Exponential Backoff Delay
Usage
calculate_backoff(attempt, base_delay = 1, max_delay = 60)
Arguments
attempt |
Current attempt number (1-based) |
base_delay |
Base delay in seconds |
max_delay |
Maximum delay in seconds |
Value
Delay in seconds with jitter
Convert S4 Class to Base64
Description
Internal function that serializes S4 class objects to base64-encoded binary format for storage in Firebase.
Usage
class_conversion(x)
classConversion(x)
Arguments
x |
The S4 class object |
Value
A list containing the base64-encoded binary data
Restore S4 Class from Base64
Description
Restores an S4 class object from base64-encoded binary data.
Usage
class_restore(data)
Arguments
data |
List containing base64Set field |
Value
The restored S4 object
Clean Firebase Path
Description
Removes leading/trailing slashes and normalizes path.
Usage
clean_path(path)
Arguments
path |
Path to clean |
Value
Cleaned path
Combine Paths
Description
Combines path segments, handling slashes properly.
Usage
combine_paths(...)
Arguments
... |
Path segments to combine |
Value
Combined path
Condition message for firebase_error
Description
Condition message for firebase_error
Usage
## S3 method for class 'firebase_error'
conditionMessage(c)
Arguments
c |
A firebase_error condition |
Value
The error message as a character string
Create User (Legacy)
Description
Legacy user creation. Use auth_create_user() instead.
Usage
createUser(projectAPI, email = "prompt", password = "prompt")
Arguments
projectAPI |
The Firebase Project API key |
email |
User email |
password |
User password |
Value
Registration response
Create Firebase Token from Auth Response
Description
Factory function to create a FirebaseToken from an authentication response.
Usage
create_token(auth_response, api_key = NULL)
Arguments
auth_response |
Response from Firebase auth API |
api_key |
Firebase API key for token refresh |
Value
A FirebaseToken object
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# After successful authentication
response <- auth_sign_in(conn, "user@example.com", "password")
token <- create_token(response, api_key = "your-api-key")
}
Database Backup (Legacy)
Description
Legacy backup function. Use rtdb_backup() instead.
Usage
dataBackup(projectURL, secretKey = "prompt", fileName)
Arguments
projectURL |
Firebase database URL |
secretKey |
Admin secret key |
fileName |
Output file name |
Value
File name
Delete Data (Legacy)
Description
Legacy delete function. Use rtdb_delete() instead.
Usage
delete(x, projectURL, directory = "main", token = "none")
Arguments
x |
Data (unused, for signature compatibility) |
projectURL |
Firebase database URL |
directory |
Database path |
token |
Authentication token |
Value
Path
Delete from Storage (Legacy)
Description
Legacy function. Use storage_delete() instead.
Usage
delete_storage(
bucket_name,
object_name,
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
bucket_name |
Storage bucket name |
object_name |
Object name to delete |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
NULL on success
Deploy R Markdown (Legacy)
Description
Legacy function to deploy R Markdown to storage. Rendering uses a temporary directory for output, intermediate files, and the knitting working directory. Use absolute paths for input resources in the document. Temporary render files are removed after the upload attempt.
Usage
deploy_rmarkdown(
rmarkdown_path,
bucket_name,
object_name,
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
rmarkdown_path |
Path to R Markdown file |
bucket_name |
Storage bucket |
object_name |
Output object name |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
Upload result
Download Data (Legacy)
Description
Legacy download function. Use rtdb_get() instead.
Usage
download(
projectURL,
fileName,
secretKey = "none",
token = "none",
isClass = FALSE
)
Arguments
projectURL |
Firebase database URL |
fileName |
Database path |
secretKey |
Admin secret key |
token |
Authentication token |
isClass |
Whether data is S4 class |
Value
Downloaded data
Create Dynamic Link
Description
Legacy interface for the discontinued Firebase Dynamic Links service. Requests to the upstream service no longer succeed.
Usage
dynlink_create(
conn = NULL,
link,
domain_uri_prefix,
short = TRUE,
social_title = NULL,
social_description = NULL,
social_image_link = NULL,
android_package_name = NULL,
android_fallback_link = NULL,
ios_bundle_id = NULL,
ios_fallback_link = NULL,
api_key = NULL
)
Arguments
conn |
Firebase connection object (or NULL to use config) |
link |
The URL you want to shorten/wrap |
domain_uri_prefix |
Your Firebase Dynamic Links domain (e.g., "https://example.page.link") |
short |
Whether to create a short link (TRUE) or unguessable link (FALSE) |
social_title |
Title for social media previews |
social_description |
Description for social media previews |
social_image_link |
Image URL for social media previews |
android_package_name |
Android app package name |
android_fallback_link |
Fallback URL for Android |
ios_bundle_id |
iOS app bundle ID |
ios_fallback_link |
Fallback URL for iOS |
api_key |
Firebase API key (used if conn is NULL) |
Value
This function always raises an error because the upstream service has been shut down.
Examples
# The retired service is unavailable; this reports an error without a request.
try(dynlink_create(
link = "https://example.com/page",
domain_uri_prefix = "https://example.page.link"
))
Convert Data for Firebase Storage
Description
Internal function that converts R objects to Firebase-compatible format. S4 class objects are converted to base64-encoded binary.
Usage
file_conversion(x)
fileConversion(x)
Arguments
x |
The input data (data.frame, list, or S4 object) |
Value
Converted data suitable for JSON serialization
Find Configuration File
Description
Searches for configuration file in standard locations:
.firedata.yml in current directory
.firedata.yml in home directory
~/.firedata/config.yml
Usage
find_config_file()
Value
Path to config file or NULL if not found
Firebase Authentication Service
Description
Functions for user authentication with Firebase Auth
Firebase Authentication Error
Description
Firebase Authentication Error
Usage
firebase_auth_error(message, code = NULL, ...)
Arguments
message |
Error message |
code |
Firebase auth error code |
... |
Additional arguments passed to firebase_error |
Value
A condition object of class firebase_auth_error
Close Firebase Connection
Description
Clears the connection's authentication state. Note that this doesn't actually close any persistent connections since the REST API is stateless.
Usage
firebase_close(conn)
Arguments
conn |
Firebase connection object |
Value
Updated connection with cleared auth state
Configuration Management for fireData
Description
Provides configuration loading and management for Firebase settings
Clear Firebase Configuration
Description
Clears session configuration values.
Usage
firebase_config_clear(keys = NULL)
Arguments
keys |
Specific keys to clear, or NULL to clear all |
Value
Invisibly returns NULL
Examples
# Clear specific keys
firebase_config_clear(c("api_key", "project_id"))
# Clear all
firebase_config_clear()
Get Firebase Configuration Value
Description
Retrieves a configuration value using the following priority:
Explicitly passed value
Session configuration (set via firebase_config_set)
Environment variables
Config file (~/.firedata/config.yml or .firedata.yml)
Default value
Usage
firebase_config_get(key, value = NULL, default = NULL, profile = "default")
Arguments
key |
Configuration key to retrieve |
value |
Explicit value (highest priority) |
default |
Default value if not found |
profile |
Configuration profile (for config file) |
Value
The configuration value or default
Examples
# Get API key from environment or config
api_key <- firebase_config_get("api_key")
# Get with explicit value override
api_key <- firebase_config_get("api_key", value = "my-api-key")
Load Configuration from File
Description
Loads configuration from a YAML file into session configuration.
Usage
firebase_config_load(path = NULL, profile = "default")
Arguments
path |
Path to config file. If NULL, searches in standard locations. |
profile |
Configuration profile to load (default: "default") |
Value
Invisibly returns the loaded configuration
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# Load from default locations
firebase_config_load()
# Load specific file
firebase_config_load("path/to/config.yml")
# Load specific profile
firebase_config_load(profile = "production")
}
Set Firebase Configuration Values for Session
Description
Sets configuration values that persist for the current R session.
Usage
firebase_config_set(...)
Arguments
... |
Named configuration values (project_id, api_key, database_url, storage_bucket) |
Value
Invisibly returns the previous values
Examples
firebase_config_set(
project_id = "my-project",
api_key = "AIzaSy..."
)
# Clear the example's session settings when finished
firebase_config_clear(c("project_id", "api_key"))
Get All Current Configuration
Description
Returns all currently set configuration values from all sources, with
sensitive values masked. Use print() to display the returned list.
Usage
firebase_config_show(profile = "default")
Arguments
profile |
Configuration profile for file lookup |
Value
Named list of all configuration values
Examples
# View current configuration
config <- firebase_config_show()
print(config)
Interactive Configuration Wizard
Description
Guides the user through setting up Firebase configuration interactively.
Usage
firebase_config_wizard(save = FALSE, path = NULL)
Arguments
save |
Whether to offer to save configuration to a file. Defaults to FALSE, which only configures the current session. |
path |
Explicit output file path, required when |
Value
Invisibly returns the configuration list
Examples
if (interactive()) {
# Run interactive setup
firebase_config_wizard()
# Optionally save to an explicitly chosen file
config_file <- tempfile(fileext = ".yml")
firebase_config_wizard(save = TRUE, path = config_file)
unlink(config_file)
}
Create a Firebase Connection
Description
Creates a connection object that stores Firebase project configuration and can be passed to various fireData functions. The connection handles configuration resolution from multiple sources (arguments, environment, config files).
Usage
firebase_connect(
project_id = NULL,
api_key = NULL,
database_url = NULL,
storage_bucket = NULL,
credentials = NULL,
token = NULL
)
Arguments
project_id |
Firebase project ID (e.g., "my-project-12345") |
api_key |
Firebase Web API key |
database_url |
Realtime Database URL. Supply the exact URL shown in the
Firebase console for regional or non-default databases. If NULL, a
US Central default URL is constructed from |
storage_bucket |
Cloud Storage bucket name. If NULL, defaults to the
current |
credentials |
Service account credentials (path to JSON file or ServiceAccountCredentials object) |
token |
User authentication token (FirebaseToken object or token string) |
Value
A firebase_connection S3 object
Examples
# Create connection with explicit values
conn <- firebase_connect(
project_id = "my-project",
api_key = "AIzaSy..."
)
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# These alternatives require your own configuration or credentials.
# Create connection from environment variables
# (Set FIREBASE_PROJECT_ID, FIREBASE_API_KEY, etc.)
conn <- firebase_connect()
# Create connection with service account
conn <- firebase_connect(
project_id = "my-project",
credentials = "path/to/service-account.json"
)
}
Firebase Connection Object
Description
Provides a connection object for Firebase operations
Credential Management for fireData
Description
Provides credential storage, retrieval, and token management
Firebase DELETE Request
Description
Firebase DELETE Request
Usage
firebase_delete(url, ...)
Arguments
url |
Request URL |
... |
Additional arguments passed to firebase_request |
Value
Parsed response
Firebase Dynamic Links Service
Description
Functions for creating Firebase Dynamic Links (short URLs)
Note
Firebase Dynamic Links shut down on August 25, 2025. These functions are retained for compatibility, but the upstream service no longer creates or serves links. Use another deep-linking provider for new projects.
Create a Firebase error condition
Description
Create a Firebase error condition
Usage
firebase_error(
message,
code = NULL,
status = NULL,
details = NULL,
class = NULL,
call = NULL
)
Arguments
message |
Error message |
code |
Firebase error code (e.g., "INVALID_PASSWORD", "USER_NOT_FOUND") |
status |
HTTP status code |
details |
Additional error details |
class |
Additional error subclass |
call |
The call that generated the error |
Value
A condition object of class firebase_error
Custom Error Classes for fireData
Description
Provides a hierarchy of error classes for Firebase operations
Cloud Firestore Service
Description
Functions for interacting with Google Cloud Firestore NoSQL database
Overview
Cloud Firestore is a flexible, scalable NoSQL cloud database. Unlike the Realtime Database which stores data as one large JSON tree, Firestore stores data in documents organized into collections.
Data Model
-
Collections: Containers for documents (like folders)
-
Documents: Individual records containing fields (like files)
-
Fields: Key-value pairs within documents
-
Subcollections: Collections nested within documents
Authentication
Firestore requires authentication. Use either:
Service account credentials (recommended for server-side)
User authentication token from
auth_sign_in()
Firebase GET Request
Description
Firebase GET Request
Usage
firebase_get(url, ...)
Arguments
url |
Request URL |
... |
Additional arguments passed to firebase_request |
Value
Parsed response
HTTP Layer for fireData
Description
Provides unified HTTP request handling for Firebase REST APIs
Firebase Network Error
Description
Firebase Network Error
Usage
firebase_network_error(message, ...)
Arguments
message |
Error message |
... |
Additional arguments passed to firebase_error |
Value
A condition object of class firebase_network_error
Firebase Not Found Error
Description
Firebase Not Found Error
Usage
firebase_not_found_error(message, path = NULL, ...)
Arguments
message |
Error message |
path |
The path that was not found |
... |
Additional arguments passed to firebase_error |
Value
A condition object of class firebase_not_found_error
Firebase PATCH Request
Description
Firebase PATCH Request
Usage
firebase_patch(url, body = NULL, ...)
Arguments
url |
Request URL |
body |
Request body |
... |
Additional arguments passed to firebase_request |
Value
Parsed response
Firebase Permission Denied Error
Description
Firebase Permission Denied Error
Usage
firebase_permission_error(message, path = NULL, ...)
Arguments
message |
Error message |
path |
The path that was denied |
... |
Additional arguments passed to firebase_error |
Value
A condition object of class firebase_permission_error
Firebase POST Request
Description
Firebase POST Request
Usage
firebase_post(url, body = NULL, ...)
Arguments
url |
Request URL |
body |
Request body |
... |
Additional arguments passed to firebase_request |
Value
Parsed response
Firebase PUT Request
Description
Firebase PUT Request
Usage
firebase_put(url, body = NULL, ...)
Arguments
url |
Request URL |
body |
Request body |
... |
Additional arguments passed to firebase_request |
Value
Parsed response
Firebase Rate Limit Error
Description
Firebase Rate Limit Error
Usage
firebase_rate_limit_error(message, retry_after = NULL, ...)
Arguments
message |
Error message |
retry_after |
Seconds to wait before retrying |
... |
Additional arguments passed to firebase_error |
Value
A condition object of class firebase_rate_limit_error
Perform HTTP Request with Retry Logic
Description
Executes an HTTP request with exponential backoff retry for transient errors.
Usage
firebase_request(
method,
url,
body = NULL,
headers = list(),
query = list(),
token = NULL,
token_type = "query",
max_retries = 3,
base_delay = 1,
timeout = 120,
encode = "json"
)
Arguments
method |
HTTP method ("GET", "POST", "PUT", "PATCH", "DELETE") |
url |
The request URL |
body |
Request body (will be JSON encoded if list) |
headers |
Named list of HTTP headers |
query |
Named list of query parameters |
token |
Authentication token (added as auth query param or Bearer header) |
token_type |
How to send token: "query" (for RTDB) or "bearer" (for other APIs) |
max_retries |
Maximum number of retry attempts |
base_delay |
Base delay in seconds for exponential backoff |
timeout |
Request timeout in seconds |
encode |
Encoding for body ("json", "form", "multipart") |
Value
Parsed response content
Firebase Realtime Database Service
Description
Functions for CRUD operations on Firebase Realtime Database
Update Connection Token
Description
Updates the authentication token on a connection.
Usage
firebase_set_token(conn, token)
Arguments
conn |
Firebase connection object |
token |
New token (FirebaseToken object or string) |
Value
Updated connection object
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
auth_result <- auth_sign_in(conn, email, password)
conn <- firebase_set_token(conn, auth_result)
}
Shiny Integration for fireData
Description
Functions to integrate Firebase authentication with Shiny apps
Firebase Cloud Storage Service
Description
Functions for file storage operations with Firebase/Google Cloud Storage
Utility Functions for fireData
Description
Internal utility functions for data conversion and path handling
Firebase Validation Error
Description
Firebase Validation Error
Usage
firebase_validation_error(message, field = NULL, ...)
Arguments
message |
Error message |
field |
The field that failed validation |
... |
Additional arguments passed to firebase_error |
Value
A condition object of class firebase_validation_error
Add Firestore Document
Description
Creates a new document with an auto-generated ID.
Usage
firestore_add(conn = NULL, collection, data, project_id = NULL, token = NULL)
Arguments
conn |
Firebase connection object |
collection |
Collection path |
data |
List of fields to store |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
The created document data including the generated ID
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
# Add document with auto-generated ID
result <- firestore_add(conn, "messages", list(
text = "Hello, Firestore!",
timestamp = Sys.time(),
author = "R User"
))
# Get the generated document ID
print(result$.id)
}
Decode Firestore Fields to R List
Description
Decode Firestore Fields to R List
Usage
firestore_decode_fields(fields)
Decode Firestore Value to R Value
Description
Decode Firestore Value to R Value
Usage
firestore_decode_value(value)
Delete Firestore Document
Description
Deletes a document from Cloud Firestore.
Usage
firestore_delete(
conn = NULL,
collection,
document,
project_id = NULL,
token = NULL
)
Arguments
conn |
Firebase connection object |
collection |
Collection path |
document |
Document ID |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
TRUE if successful
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
# Delete a document
firestore_delete(conn, "users", "user123")
}
Encode R List to Firestore Fields
Description
Encode R List to Firestore Fields
Usage
firestore_encode_fields(data)
Encode R Value to Firestore Value
Description
Encode R Value to Firestore Value
Usage
firestore_encode_value(value)
Get Firestore Document
Description
Retrieves a single document from Cloud Firestore.
Usage
firestore_get(
conn = NULL,
collection,
document,
project_id = NULL,
token = NULL
)
Arguments
conn |
Firebase connection object |
collection |
Collection path (e.g., "users" or "users/uid/posts") |
document |
Document ID |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
Document data as a list, or NULL if not found
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
conn <- firebase_set_token(conn, auth_sign_in(conn, "user@example.com", "password"))
# Get a single document
user <- firestore_get(conn, "users", "user123")
print(user$name)
# Get from subcollection
post <- firestore_get(conn, "users/user123/posts", "post456")
}
List Firestore Documents
Description
Lists documents in a collection.
Usage
firestore_list(
conn = NULL,
collection,
page_size = 100,
page_token = NULL,
order_by = NULL,
project_id = NULL,
token = NULL
)
Arguments
conn |
Firebase connection object |
collection |
Collection path |
page_size |
Maximum number of documents to return (default 100) |
page_token |
Token for pagination (from previous response) |
order_by |
Field to order by (prefix with "-" for descending) |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
List containing documents and optional nextPageToken
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
# List all users (up to 100)
result <- firestore_list(conn, "users")
for (user in result$documents) {
print(user$name)
}
# Paginate through results
result <- firestore_list(conn, "users", page_size = 10)
while (!is.null(result$nextPageToken)) {
result <- firestore_list(conn, "users", page_size = 10,
page_token = result$nextPageToken)
}
}
Parse Firestore Document Response
Description
Parse Firestore Document Response
Usage
firestore_parse_document(doc)
Query Firestore Documents
Description
Runs a structured query against a Firestore collection.
Usage
firestore_query(conn = NULL, collection, project_id = NULL, token = NULL)
Arguments
conn |
Firebase connection object |
collection |
Collection path to query |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
A firestore_query object for building the query
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
# Query with filters
results <- firestore_query(conn, "users") |>
fs_where("age", ">=", 18) |>
fs_where("active", "==", TRUE) |>
fs_order_by("name") |>
fs_limit(10) |>
fs_execute()
}
Set Firestore Document
Description
Creates or overwrites a document in Cloud Firestore.
Usage
firestore_set(
conn = NULL,
collection,
document,
data,
project_id = NULL,
token = NULL
)
Arguments
conn |
Firebase connection object |
collection |
Collection path |
document |
Document ID |
data |
List of fields to store |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
The created/updated document data
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
# Create or overwrite a document
firestore_set(conn, "users", "user123", list(
name = "John Doe",
email = "john@example.com",
age = 30,
active = TRUE
))
}
Update Firestore Document
Description
Updates specific fields in a document without overwriting the entire document.
Usage
firestore_update(
conn = NULL,
collection,
document,
data,
project_id = NULL,
token = NULL
)
Arguments
conn |
Firebase connection object |
collection |
Collection path |
document |
Document ID |
data |
List of fields to update |
project_id |
Project ID (uses connection or config if NULL) |
token |
Authentication token (uses connection if NULL) |
Value
The updated document data
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project")
# Update only specific fields
firestore_update(conn, "users", "user123", list(
lastLogin = Sys.time(),
loginCount = 42
))
}
Format Bytes for Display
Description
Format Bytes for Display
Usage
format_bytes(bytes)
Arguments
bytes |
Number of bytes |
Value
Human-readable string
Execute Firestore Query
Description
Executes a Firestore query and returns the results.
Usage
fs_execute(query)
Arguments
query |
A firestore_query object |
Value
List of documents matching the query
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
results <- firestore_query(conn, "products") |>
fs_where("price", "<", 100) |>
fs_order_by("price", "asc") |>
fs_limit(20) |>
fs_execute()
}
Limit Firestore Query Results
Description
Limits the number of documents returned by a query.
Usage
fs_limit(query, n)
Arguments
query |
A firestore_query object |
n |
Maximum number of documents to return |
Value
Updated firestore_query object
Offset Firestore Query Results
Description
Skips a number of documents before returning results.
Usage
fs_offset(query, n)
Arguments
query |
A firestore_query object |
n |
Number of documents to skip |
Value
Updated firestore_query object
Add Order By to Firestore Query
Description
Adds ordering to a Firestore query.
Usage
fs_order_by(query, field, direction = "asc")
Arguments
query |
A firestore_query object |
field |
Field name to order by |
direction |
Sort direction: "asc" or "desc" |
Value
Updated firestore_query object
Select Fields in Firestore Query
Description
Specifies which fields to return in query results.
Usage
fs_select(query, ...)
Arguments
query |
A firestore_query object |
... |
Field names to select |
Value
Updated firestore_query object
Add Where Filter to Firestore Query
Description
Adds a field filter to a Firestore query.
Usage
fs_where(query, field, op, value)
Arguments
query |
A firestore_query object |
field |
Field name to filter on |
op |
Comparison operator: "==", "!=", "<", "<=", ">", ">=", "array-contains", "array-contains-any", "in", "not-in" |
value |
Value to compare against |
Value
Updated firestore_query object
Examples
conn <- firebase_connect(project_id = "my-project")
query <- firestore_query(conn, "users") |>
fs_where("age", ">=", 21) |>
fs_where("status", "==", "active")
Generate Random ID
Description
Generates a random ID similar to Firebase push IDs.
Usage
generate_id(length = 20)
Arguments
length |
Length of ID (default: 20) |
Value
Random ID string
Get Value from Config File
Description
Get Value from Config File
Usage
get_config_file_value(key, profile = "default")
Arguments
key |
Configuration key |
profile |
Configuration profile |
Value
Value or NULL
Get Token from Connection
Description
Extracts or resolves an authentication token from the connection.
Usage
get_connection_token(conn, require_auth = FALSE)
Arguments
conn |
Firebase connection object |
require_auth |
Whether to error if no token available |
Value
Token string or NULL
Create Dynamic Link (Legacy)
Description
Legacy function. Use dynlink_create() instead.
Usage
get_dynamic_link(
project_api,
domain,
link,
short = TRUE,
social_title = "",
social_description = "",
social_image_link = ""
)
Arguments
project_api |
Firebase API key |
domain |
Dynamic Links domain |
link |
URL to shorten |
short |
Whether to create short link |
social_title |
Social preview title |
social_description |
Social preview description |
social_image_link |
Social preview image |
Value
This function always raises an error because the upstream service has been shut down.
Get OAuth2 Token for Google APIs
Description
Creates an OAuth2 token for accessing Google APIs.
Usage
get_oauth_token(client_id, client_secret, scopes, cache = FALSE)
Arguments
client_id |
OAuth2 client ID |
client_secret |
OAuth2 client secret |
scopes |
OAuth2 scopes to request |
cache |
Whether to cache the token |
Value
An httr OAuth2 token object
Get Storage Metadata (Legacy)
Description
Legacy function. Use storage_get_metadata() instead.
Usage
get_storage(
bucket_name,
object_name,
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
bucket_name |
Storage bucket name |
object_name |
Object name |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
Object metadata
Get OAuth Token for Storage Operations
Description
Internal helper to get an OAuth token for storage operations.
Usage
get_storage_token(
conn,
client_id = NULL,
client_secret = NULL,
read_only = FALSE
)
Arguments
conn |
Firebase connection object |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
read_only |
Whether to request read-only scope |
Value
Access token string
Get Storage URL (Legacy)
Description
Legacy function. Use storage_get_url() instead.
Usage
get_url(
bucket_name,
object_name,
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
bucket_name |
Storage bucket name |
object_name |
Object name |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
Download URL
Get User Token
Description
Gets the Firebase token from authenticated user in Shiny context.
Usage
get_user_token(user)
Arguments
user |
The reactiveValues object used with shiny_auth_server |
Value
The ID token string or NULL if not authenticated
Get Storage Token with Read-Only Access (Legacy)
Description
Legacy function for OAuth token.
Usage
google_devstorage_read_only(
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
OAuth token
Get Storage Token with Read/Write Access (Legacy)
Description
Legacy function for OAuth token.
Usage
google_devstorage_read_write(
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
OAuth token
Get Firestore Token (Legacy)
Description
Legacy function for Firestore OAuth token.
Usage
google_firestore(
web_client_id = "prompt",
web_client_secret = "prompt",
cache = FALSE
)
Arguments
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
cache |
Whether to cache token |
Value
OAuth token
Google Login (Legacy)
Description
Legacy Google login. Use auth_google() instead.
Usage
google_login(
project_api,
web_client_id = "prompt",
web_client_secret = "prompt",
request_uri,
redirect_uri = httr::oauth_callback(),
return_idp_credential = TRUE,
cache = FALSE
)
Arguments
project_api |
Firebase API key |
web_client_id |
Google OAuth client ID |
web_client_secret |
Google OAuth client secret |
request_uri |
Request URI |
redirect_uri |
Redirect URI |
return_idp_credential |
Whether to return IDP credential |
cache |
Whether to cache token |
Value
Authentication response
Check Authentication Status
Description
Helper to check if user is authenticated in Shiny context.
Usage
is_authenticated(user)
Arguments
user |
The reactiveValues object used with shiny_auth_server |
Value
TRUE if user is logged in, FALSE otherwise
Check if Data is Base64-Encoded S4 Object
Description
Check if Data is Base64-Encoded S4 Object
Usage
is_encoded_s4(data)
Arguments
data |
Data to check |
Value
TRUE if data appears to be a base64-encoded S4 object
Check if Response Indicates Error
Description
Check if Response Indicates Error
Usage
is_error(response)
Arguments
response |
An httr response object |
Value
TRUE if error, FALSE otherwise
Check if Object is a Firebase Connection
Description
Check if Object is a Firebase Connection
Usage
is_firebase_connection(x)
Arguments
x |
Object to check |
Value
TRUE if x is a firebase_connection
Check if Response Indicates Success
Description
Check if Response Indicates Success
Usage
is_success(response)
Arguments
response |
An httr response object |
Value
TRUE if successful, FALSE otherwise
Validate Email Format
Description
Basic email format validation.
Usage
is_valid_email(email)
Arguments
email |
Email address to validate |
Value
TRUE if valid format, FALSE otherwise
Validate Firebase Project ID
Description
Firebase project IDs must be 6-30 characters, lowercase letters, numbers, and hyphens only.
Usage
is_valid_project_id(project_id)
Arguments
project_id |
Project ID to validate |
Value
TRUE if valid, FALSE otherwise
Create Connection from Legacy Parameters
Description
Helper to create a connection from the legacy API parameters (projectURL, projectAPI, token, secretKey).
Usage
legacy_to_connection(
projectURL = NULL,
projectAPI = NULL,
token = NULL,
secretKey = NULL
)
Arguments
projectURL |
Firebase database URL |
projectAPI |
Firebase API key |
token |
Authentication token |
secretKey |
Database secret key (legacy) |
Value
A firebase_connection object
List Storage (Legacy)
Description
Legacy function. Use storage_list() instead.
Usage
list_storage(
bucket_name,
web_client_id = "prompt",
web_client_secret = "prompt"
)
Arguments
bucket_name |
Storage bucket name |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
Value
List of objects
Load Service Account Credentials
Description
Creates ServiceAccountCredentials from a file or environment.
Usage
load_service_account(path = NULL)
Arguments
path |
Path to service account JSON file (optional) |
Value
A ServiceAccountCredentials object
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# From file
creds <- load_service_account("path/to/service-account.json")
# From GOOGLE_APPLICATION_CREDENTIALS environment variable
creds <- load_service_account()
}
OAuth Login (Legacy)
Description
Legacy OAuth login. Use auth_oauth() instead.
Usage
o_auth_login(project_api, request_uri, post_body, return_idp_credential)
Arguments
project_api |
Firebase API key |
request_uri |
Request URI |
post_body |
OAuth post body |
return_idp_credential |
Whether to return IDP credential |
Value
Authentication response
OAuth2 Token Helpers
Description
Functions to obtain OAuth2 tokens for various Google/Firebase services.
Parse Firebase API Error Response
Description
Parses error responses from Firebase REST APIs and returns the appropriate error object.
Usage
parse_firebase_error(response)
Arguments
response |
An httr response object |
Value
A firebase_error subclass based on the error type
Parse HTTP Response
Description
Parse HTTP Response
Usage
parse_response(response)
Arguments
response |
An httr response object |
Value
Parsed response content
Patch Data (Legacy)
Description
Legacy patch function. Use rtdb_update() instead.
Usage
patch(x, projectURL, directory = "main", token = "none")
Arguments
x |
Data to update |
projectURL |
Firebase database URL |
directory |
Database path |
token |
Authentication token |
Value
Path
Sanitize Firebase Path
Description
Replaces disallowed characters in Firebase paths with hyphens. Firebase paths cannot contain: . $ # [ ] /
[ ]: R:%20
Usage
path_sanitize(path)
path_check(path)
Arguments
path |
The database path string |
Value
The sanitized path string
Examples
# Path with invalid characters
path_sanitize("users/john.doe")
# Returns: "users-john-doe" with a warning
# Valid path passes through unchanged
path_sanitize("users-johndoe")
# Returns: "users-johndoe"
Print Firebase Connection
Description
Print Firebase Connection
Usage
## S3 method for class 'firebase_connection'
print(x, ...)
Arguments
x |
A firebase_connection object |
... |
Additional arguments (ignored) |
Value
Invisibly returns x
Print method for firebase_error
Description
Print method for firebase_error
Usage
## S3 method for class 'firebase_error'
print(x, ...)
Arguments
x |
A firebase_error object |
... |
Additional arguments (ignored) |
Value
Invisibly returns x
Print Firestore Query
Description
Print Firestore Query
Usage
## S3 method for class 'firestore_query'
print(x, ...)
Arguments
x |
A firestore_query object |
... |
Additional arguments (ignored) |
Value
Invisibly returns x
Print Query
Description
Print Query
Usage
## S3 method for class 'rtdb_query'
print(x, ...)
Arguments
x |
Query object |
... |
Ignored |
Value
Invisibly returns x
Prompt for Value if Not Set
Description
Internal helper to prompt user for a value if not already set. Supports both interactive prompts and environment variable fallback.
Usage
prompt_if_missing(value, key = NULL, prompt = NULL, secret = FALSE)
Arguments
value |
Current value |
key |
Configuration key for lookup |
prompt |
Prompt message for interactive input |
secret |
Whether to hide input (for passwords) |
Value
The resolved value
Put Data (Legacy)
Description
Legacy put function. Use rtdb_set() instead.
Usage
put(x, projectURL, directory = "main", token = "none")
Arguments
x |
Data to write |
projectURL |
Firebase database URL |
directory |
Database path |
token |
Authentication token |
Value
Path
End Query at Value
Description
End Query at Value
Usage
query_end_at(query, value)
Arguments
query |
Query builder object |
value |
Ending value (inclusive) |
Value
Updated query builder
Filter Query by Exact Value
Description
Filter Query by Exact Value
Usage
query_equal_to(query, value)
Arguments
query |
Query builder object |
value |
Value to match exactly |
Value
Updated query builder
Execute Query
Description
Execute Query
Usage
query_execute(query, token = NULL)
Arguments
query |
Query builder object |
token |
Authentication token (optional) |
Value
Query results
Limit Query to First N Results
Description
Limit Query to First N Results
Usage
query_limit_to_first(query, n)
Arguments
query |
Query builder object |
n |
Number of results |
Value
Updated query builder
Limit Query to Last N Results
Description
Limit Query to Last N Results
Usage
query_limit_to_last(query, n)
Arguments
query |
Query builder object |
n |
Number of results |
Value
Updated query builder
Order Query by Field
Description
Order Query by Field
Usage
query_order_by(query, field)
Arguments
query |
Query builder object |
field |
Field to order by ("$key", "$value", "$priority", or child key) |
Value
Updated query builder
Start Query at Value
Description
Start Query at Value
Usage
query_start_at(query, value)
Arguments
query |
Query builder object |
value |
Starting value (inclusive) |
Value
Updated query builder
Reset Password (Legacy)
Description
Legacy password reset. Use auth_reset_password() instead.
Usage
resetPassword(projectAPI, email)
Arguments
projectAPI |
The Firebase Project API key |
email |
User email |
Value
Success or warning message
Resolve Credentials
Description
Attempts to resolve credentials from various sources:
Explicitly provided token/credentials
Service account from environment
Cached user credentials
Interactive OAuth (if in interactive session)
Usage
resolve_credentials(token = NULL, service_account = NULL, require_auth = FALSE)
Arguments
token |
Existing token or NULL |
service_account |
Path to service account JSON |
require_auth |
Whether authentication is required |
Value
A token string or NULL
Convert Response to Data Frame
Description
Converts Firebase response (typically a named list of records) to a data frame.
Usage
response_to_df(data, id_column = ".id")
Arguments
data |
Firebase response data |
id_column |
Name of column to store record IDs (default: ".id") |
Value
A data frame
Backup Realtime Database
Description
Downloads the entire database to a JSON file.
Usage
rtdb_backup(conn, file_name, token = NULL)
Arguments
conn |
Firebase connection object |
file_name |
Output file path |
token |
Authentication token (typically admin/service account) |
Value
The file name where backup was saved
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(
project_id = "my-project",
credentials = "service-account.json"
)
backup_file <- tempfile(fileext = ".json")
rtdb_backup(conn, backup_file)
unlink(backup_file)
}
Delete Data from Realtime Database
Description
Removes data at the specified path.
Usage
rtdb_delete(conn, path, token = NULL)
Arguments
conn |
Firebase connection object |
path |
Database path to delete |
token |
Authentication token (overrides connection token) |
Value
The path that was deleted
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
# Delete user
rtdb_delete(conn, "users/user123")
}
Get Data from Realtime Database
Description
Retrieves data from the specified path in the Realtime Database.
Usage
rtdb_get(conn, path, shallow = FALSE, is_class = FALSE, token = NULL)
Arguments
conn |
Firebase connection object |
path |
Database path (e.g., "users/user123") |
shallow |
If TRUE, returns only keys without values (for large datasets) |
is_class |
If TRUE, data is decoded as an S4 class object |
token |
Authentication token (overrides connection token) |
Value
The data at the specified path, or NULL if not found
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
# Get all users
users <- rtdb_get(conn, "users")
# Get specific user
user <- rtdb_get(conn, "users/user123")
# Get only keys (shallow read)
keys <- rtdb_get(conn, "users", shallow = TRUE)
}
Push Data to Realtime Database (Create with Auto-ID)
Description
Adds data to a list with an auto-generated unique key.
Usage
rtdb_push(conn, path, data, token = NULL)
Arguments
conn |
Firebase connection object |
path |
Database path (parent location) |
data |
Data to push |
token |
Authentication token (overrides connection token) |
Value
The full path including the generated key
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
# Push new message (auto-generates key)
path <- rtdb_push(conn, "messages", list(text = "Hello", timestamp = Sys.time()))
# Returns something like "messages/-NxYz..."
}
Create Database Query
Description
Creates a query builder for filtering and sorting database queries.
Usage
rtdb_query(conn, path)
Arguments
conn |
Firebase connection object |
path |
Database path to query |
Value
A query builder object
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
# Query users ordered by age, limited to 10
results <- rtdb_query(conn, "users") |>
query_order_by("age") |>
query_start_at(18) |>
query_limit_to_first(10) |>
query_execute()
}
Set Data in Realtime Database (Overwrite)
Description
Writes data to the specified path, overwriting any existing data. Use rtdb_update() for partial updates.
Usage
rtdb_set(conn, path, data, token = NULL)
Arguments
conn |
Firebase connection object |
path |
Database path |
data |
Data to write (data.frame, list, or S4 object) |
token |
Authentication token (overrides connection token) |
Value
The path where data was written
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
# Set user data
rtdb_set(conn, "users/user123", list(name = "John", age = 30))
# Set data frame
rtdb_set(conn, "data/mtcars", mtcars)
}
Update Data in Realtime Database (Partial Update)
Description
Updates specific fields at the specified path without overwriting other existing data. Use rtdb_set() to completely overwrite.
Usage
rtdb_update(conn, path, data, token = NULL)
Arguments
conn |
Firebase connection object |
path |
Database path |
data |
Data to update (only specified fields will be changed) |
token |
Authentication token (overrides connection token) |
Value
The path where data was updated
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", api_key = "...")
# Update only the age field
rtdb_update(conn, "users/user123", list(age = 31))
}
Create Shiny Authentication Server
Description
Creates a login overlay for Shiny applications with support for email/password, Google OAuth, and anonymous authentication.
Usage
shiny_auth_server(
user,
input,
output,
credentials = TRUE,
goauth = TRUE,
anonymous = TRUE,
project_api = NULL,
web_client_id = NULL,
web_client_secret = NULL,
request_uri = NULL
)
Arguments
user |
A reactiveValues object with a |
input |
Shiny input object |
output |
Shiny output object |
credentials |
Enable email/password login (default: TRUE) |
goauth |
Enable Google OAuth login (default: TRUE) |
anonymous |
Enable anonymous login (default: TRUE) |
project_api |
Firebase API key |
web_client_id |
Google OAuth client ID (required if goauth = TRUE) |
web_client_secret |
Google OAuth client secret (required if goauth = TRUE) |
request_uri |
OAuth redirect URI |
Value
A Shiny UI element containing the login form
Examples
if (interactive()) {
library(shiny)
library(fireData)
ui <- fluidPage(
shinyjs::useShinyjs(),
uiOutput("app")
)
server <- function(input, output, session) {
USER <- reactiveValues(Logged = FALSE)
output$app <- renderUI({
if (!USER$Logged) {
shiny_auth_server(
user = USER,
input = input,
output = output,
project_api = "your-api-key",
web_client_id = "your-client-id",
web_client_secret = "your-client-secret",
request_uri = "http://localhost"
)
} else {
# Your main app UI
tagList(
h1("Welcome!"),
actionButton("logout", "Logout")
)
}
})
}
shinyApp(ui, server)
}
Shiny Authentication UI Helper
Description
Creates a styled login panel for Shiny apps. Use with shiny_auth_server() for complete authentication.
Usage
shiny_auth_ui(title = "Sign In")
Arguments
title |
Title shown on the login panel |
Value
A Shiny UI element
Examples
if (interactive()) {
ui <- shiny::fluidPage(
shinyjs::useShinyjs(),
shiny_auth_ui("Sign In")
)
}
Stop with Firebase Error
Description
Convenience function to raise a Firebase error
Usage
stop_firebase(type = "generic", message, ...)
Arguments
type |
Type of error: "auth", "permission", "not_found", "validation", "network", "rate_limit", or "generic" |
message |
Error message |
... |
Additional arguments passed to the error constructor |
Delete File from Storage
Description
Deletes a file from Firebase Cloud Storage.
Usage
storage_delete(conn, object_name, client_id = NULL, client_secret = NULL)
Arguments
conn |
Firebase connection object |
object_name |
Name/path of the object to delete |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
Value
NULL on success
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
storage_delete(conn, "images/old-photo.jpg")
}
Download File from Storage
Description
Downloads a file from Firebase Cloud Storage.
Usage
storage_download(
conn,
object_name,
dest_file = NULL,
client_id = NULL,
client_secret = NULL
)
Arguments
conn |
Firebase connection object |
object_name |
Name/path of the object in storage |
dest_file |
Local destination path (if NULL, returns content) |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
Value
If dest_file is NULL, returns file content; otherwise returns dest_file path
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# Download to file
dest_file <- tempfile(fileext = ".jpg")
storage_download(conn, "images/photo.jpg", dest_file)
unlink(dest_file)
# Download to memory
content <- storage_download(conn, "data/config.json")
}
Get Storage Object Metadata
Description
Retrieves metadata for a storage object.
Usage
storage_get_metadata(conn, object_name, client_id = NULL, client_secret = NULL)
Arguments
conn |
Firebase connection object |
object_name |
Name/path of the object |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
Value
Object metadata
Get Download URL for Storage Object
Description
Generates a download URL for a storage object.
Usage
storage_get_url(conn, object_name, client_id = NULL, client_secret = NULL)
Arguments
conn |
Firebase connection object |
object_name |
Name/path of the object |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
Value
Download URL string
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
url <- storage_get_url(conn, "images/photo.jpg")
if (interactive()) {
utils::browseURL(url)
}
}
List Files in Storage
Description
Lists all files in a storage bucket or prefix.
Usage
storage_list(
conn,
prefix = NULL,
delimiter = NULL,
max_results = 1000,
client_id = NULL,
client_secret = NULL
)
Arguments
conn |
Firebase connection object |
prefix |
Filter results to objects with this prefix |
delimiter |
Use "/" to list only immediate children |
max_results |
Maximum number of results |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
Value
List of storage objects
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
# List all files
files <- storage_list(conn)
# List files in a "folder"
images <- storage_list(conn, prefix = "images/")
}
Upload File to Storage
Description
Uploads a file to Firebase Cloud Storage.
Usage
storage_upload(
conn,
file_path,
object_name,
content_type = NULL,
predefined_acl = NULL,
client_id = NULL,
client_secret = NULL
)
Arguments
conn |
Firebase connection object |
file_path |
Local path to the file to upload |
object_name |
Name/path for the object in storage (e.g., "images/photo.jpg") |
content_type |
MIME type (auto-detected if NULL) |
predefined_acl |
Optional predefined object ACL (for example, "publicRead" or "private"). The default NULL uses bucket IAM and is compatible with uniform bucket-level access. |
client_id |
OAuth client ID (for user auth) |
client_secret |
OAuth client secret (for user auth) |
Value
Storage object metadata including URL
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
conn <- firebase_connect(project_id = "my-project", storage_bucket = "my-bucket")
# Upload with service account
result <- storage_upload(conn, "local/photo.jpg", "images/photo.jpg")
# Get the public URL
print(result$url)
}
Upload Folder to Storage
Description
Uploads all files from a local folder to storage.
Usage
storage_upload_folder(
conn,
folder_path,
prefix = "",
client_id = NULL,
client_secret = NULL
)
Arguments
conn |
Firebase connection object |
folder_path |
Local folder path |
prefix |
Storage prefix/path for uploaded files |
client_id |
OAuth client ID |
client_secret |
OAuth client secret |
Value
List of upload results
Examples
# Requires your own Firebase configuration, credentials and example resources.
# Adapt the placeholders and set FIREDATA_RUN_EXAMPLES=true to opt in.
if (identical(Sys.getenv("FIREDATA_RUN_EXAMPLES"), "true")) {
results <- storage_upload_folder(conn, "local/images", "images")
}
Upload Data (Legacy)
Description
Legacy upload function. Use rtdb_push() instead.
Usage
upload(x, projectURL, directory = "main", token = "none")
Arguments
x |
Data to upload |
projectURL |
Firebase database URL |
directory |
Database path |
token |
Authentication token |
Value
Path with generated key
Upload Folder (Legacy)
Description
Legacy function. Use storage_upload_folder() instead.
Usage
upload_folder(
bucket_name,
web_client_id = "prompt",
web_client_secret = "prompt",
folder_path
)
Arguments
bucket_name |
Storage bucket name |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
folder_path |
Local folder path |
Value
List of upload results
Upload to Storage (Legacy)
Description
Legacy function. Use storage_upload() instead.
Usage
upload_storage(
bucket_name,
object_name,
web_client_id = "prompt",
web_client_secret = "prompt",
file_path = NULL,
predefined_acl = "publicRead"
)
Arguments
bucket_name |
Storage bucket name |
object_name |
Object name in storage |
web_client_id |
OAuth client ID |
web_client_secret |
OAuth client secret |
file_path |
Local file path |
predefined_acl |
Access control |
Value
Storage object metadata