| Title: | Integrates 'Google Firebase' Authentication Storage, and 'Analytics' with 'Shiny' |
|---|---|
| Description: | Authenticate users in 'Shiny' applications using 'Google Firebase' with any of the many methods provided; email and password, email link, or using a third-party provider such as 'Github', 'Twitter', or 'Google'. Use 'Firebase Storage' to store files securely, and leverage 'Firebase Analytics' to easily log events and better understand your audience. |
| Authors: | John Coene [aut, cph], David Munoz Tord [cre, ctb] (ORCID: <https://orcid.org/0000-0001-7954-8295>), Juha Itkonen [ctb] |
| Maintainer: | David Munoz Tord <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.2 |
| Built: | 2026-05-25 10:23:31 UTC |
| Source: | https://github.com/johncoene/firebase |
Analytics
Analytics
An object of class Analytics.
firebase::Firebase -> Analytics
new()
Analytics$new(enable = TRUE)
enableWhether to internally enable analytics
see launch method.
Initialise
Initialise an analytics object.
launch()
Analytics$launch()
Launch
Launch the analytics tracking.
Note that analytics is not launched by the
constructor in order to be able to enable
or disable the tracking prior to the launch.
This is because once Google Analytics is
launched it cannot be disabled. If needed
ask the user before running this method.
The enabling and disabling of tracking provided
by the package is only internal, e.g.: disabling
tracking during a session will stop the log_event
method from registering event but default Google
Analytics will still be running.
enable()
Analytics$enable()
Enable Tracking Internally enables tracking.
disable()
Analytics$disable()
Disable Tracking Internally disables tracking: running methods from this instance of the class will not actually register with Google Analytics.
log_event()
Analytics$log_event(event, params = NULL)
eventEvent to log choose from this list of supported events.
paramsEvent parameters.
Log Event
Log an event.
set_user_properties()
Analytics$set_user_properties(...)
...Named arguments defining the properties of the user.
Set user properties
clone()
The objects of this class are cloneable with this method.
Analytics$clone(deep = FALSE)
deepWhether to make a deep clone.
Configure Firebase, either using a config file or by setting environment variables (see section below).
firebase_config( api_key, project_id, auth_domain = NULL, storage_bucket = NULL, app_id = NULL, database_url = NULL, overwrite = FALSE )firebase_config( api_key, project_id, auth_domain = NULL, storage_bucket = NULL, app_id = NULL, database_url = NULL, overwrite = FALSE )
api_key |
API key of your project. |
project_id |
Id of your web project. |
auth_domain |
Authentication domain, if |
storage_bucket |
URl to the bucket. if |
app_id |
Application ID, necessary for Analytics. |
database_url |
URL to the database, required to use
the |
overwrite |
Whether to overwrite any existing configuration file. |
Creates the configuration file necessary to running fireblaze. Note that if you changed the project you must use said ID here, not the one originally created by Google.
Classes of the package look first for the configuration file then, if not found look for the environment variables.
Path to file.
FIREBASE_API_KEY
FIREBASE_PROJECT_ID
FIREBASE_AUTH_DOMAIN
FIREBASE_STORAGE_BUCKET
FIREBASE_APP_ID
FIREBASE_DATABASE_URL
Do not share this file with anyone.
## Not run: firebase_config("xXxxx", "my-project")## Not run: firebase_config("xXxxx", "my-project")
Include dependencies in your Shiny application.
use_firebase must be included in
every application.
useFirebase(analytics = FALSE, firestore = FALSE) useFirebaseUI(...) firebaseUIContainer()useFirebase(analytics = FALSE, firestore = FALSE) useFirebaseUI(...) firebaseUIContainer()
analytics |
Deprecated. Whether to include analytics. |
firestore |
Whether to include firestore. |
... |
Ignored, for backwards compatibility. |
Place useFirebaseUI where you want
the pre-built UI to be placed. Otherwise one
No return value, called for side effects.
useFirebase Is required for every app that uses this package
useFirebaseUI Is required for applications that use FirebaseUI
firebaseUIContainer To place the container of the pre-built UI where desired
Core Firebase class.
An object of class Firebase.
sessionA valid Shiny session.
new()
Firebase$new( config_path = "firebase.rds", session = shiny::getDefaultReactiveDomain() )
config_pathPath to the configuration file as created by firebase_config.
sessionA valid shiny session.
Initialise Firebase
Initialises the Firebase application client-side.
Invisibly return the class.
expose_app()
Firebase$expose_app()
Expose App
Expose the firebaseApp object product of initializeApp() by
attaching it to the window: access it with window.firebaseApp.
print()
Firebase$print()
Print the class
clone()
The objects of this class are cloneable with this method.
Firebase$clone(deep = FALSE)
deepWhether to make a deep clone.
Use firebase to manage authentications.
An object of class FirebaseAuth.
firebase::Firebase -> FirebaseAuth
signed_inRead the signed in user.
signed_upRead the signed in user.
new()
FirebaseAuth$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialise firebase authentication
print()
FirebaseAuth$print()
Print the class
sign_out()
FirebaseAuth$sign_out()
Signs out user
self
get_sign_out()
FirebaseAuth$get_sign_out()
Get signed out results
A list of length 2 containing success a boolean
indicating wherther signing out was successful and response
containing sucessful or the error.
get_signed_in()
FirebaseAuth$get_signed_in()
Signed in user details triggered when auth states changes
A list of length 2 containing success a boolean
indicating wherther signing in was successful and response
containing the user object or NULL if signing in failed.
get_signed_up()
FirebaseAuth$get_signed_up()
Get results of a sign up
A list of length 2 containing success a boolean
indicating wherther signing in was successful and response
containing the user object or NULL if signing in failed.
is_signed_in()
FirebaseAuth$is_signed_in()
Check whether use is signed in
A boolean indicating whether user has successfully signed in.
req_sign_in()
FirebaseAuth$req_sign_in()
Makes Shiny output, observer, or reactive require the user to be signed in
req_sign_out()
FirebaseAuth$req_sign_out()
Makes Shiny output, observer, or reactive require the user to be signed out
set_language_code()
FirebaseAuth$set_language_code(code)
codeiso639-1 language code.
Set language code for auth provider
self
delete_user()
FirebaseAuth$delete_user()
Delete the user
self
get_delete_user()
FirebaseAuth$get_delete_user()
Get result of user deletion
A list of length 2 containing success a boolean
indicating wherther deletion was successful and response
containing either successful string or the error if signing in failed.
expose_auth()
FirebaseAuth$expose_auth()
Expose Auth
Expose the firebaseAuth object the product of the authentication
attaching it to the window: access it with window.firebaseAuth.
get_access_token()
FirebaseAuth$get_access_token()
Get user access token
User's access token
clear()
FirebaseAuth$clear()
Clear user session
This clears the login internally and will retrigger a JWT token check, only useful if you are running really long sessions.
request_id_token()
FirebaseAuth$request_id_token()
Request the users' ID Token
Used to retrieved the user's ID token useful to connect with other Google APIs and make request on the user's behalf. This executes the request for the id token, this request can only be made once the user is signed in.
The actual id token is obtained with the get_id_token
method.
get_id_token()
FirebaseAuth$get_id_token()
Retrieve the users' ID Token
Also see request_id_token.
the id token (invisibly).
clone()
The objects of this class are cloneable with this method.
FirebaseAuth$clone(deep = FALSE)
deepWhether to make a deep clone.
Sign in the user by emailing them a link.
An object of class FirebaseEmailLink.
firebase::Firebase -> firebase::FirebaseAuth -> FirebaseEmailLink
email_verificationEmail verification results
email_sentEmail send results
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()new()
FirebaseEmailLink$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialiases Firebase Email Link
Initialises the Firebase application client-side.
config()
FirebaseEmailLink$config(url, ...)
urlThe link is handled in the web action widgets, this is the deep link in the continueUrl query parameter. Likely, your shiny application link.
...Any other parameter from the official documentation.
Configure
\dontrun{
f <- FirebaseEmailLink$
new()$ # create
config(url = "https://me.shinyapps.io/myApp/")
}
send_email()
FirebaseEmailLink$send_email(email)
emailEmail to send verification to.
Send email verification link.
self
\dontrun{
f <- FirebaseEmailLink$
new()$ # create
config(url = "https://me.shinyapps.io/myApp/")$
send("[email protected]")
}
get_email_sent()
FirebaseEmailLink$get_email_sent()
Get whether email verification was correctly sent.
A list of length 2 containing success a boolean
indicating wherther sending the email was successful and response
containing the email used to sign in or the error if sending failed.
get_email_verification()
FirebaseEmailLink$get_email_verification()
Get whether user is signing in from email verification.
A list of length 2 containing success a boolean
indicating wherther signing in from the verification link was successful and response
containing the result of the sign in or the error if signing in failed.
clone()
The objects of this class are cloneable with this method.
FirebaseEmailLink$clone(deep = FALSE)
deepWhether to make a deep clone.
Other methods to pick up whether user signs in still apply. This is for added security measures.
library(shiny) library(firebase) old <- options() options(shiny.port = 3000) ui <- fluidPage( useFirebase(), textInput("email", "Your email"), actionButton("submit", "Submit") ) server <- function(input, output){ f <- FirebaseEmailLink$ new()$ config(url = "http://127.0.0.1:3000") observeEvent(input$submit, { if(input$email == "") return() f$send(input$email) }) observeEvent(f$get_email_sent(), { sent <- f$get_email_sent() if(sent$success) showNotification("Email sent", type = "message") }) observeEvent(f$get_email_verification(), { print(f$get_email_verification()) }) } if(interactive()){ shinyApp(ui, server) } options(old) ## ------------------------------------------------ ## Method `FirebaseEmailLink$config` ## ------------------------------------------------ ## Not run: f <- FirebaseEmailLink$ new()$ # create config(url = "https://me.shinyapps.io/myApp/") ## End(Not run) ## ------------------------------------------------ ## Method `FirebaseEmailLink$send_email` ## ------------------------------------------------ ## Not run: f <- FirebaseEmailLink$ new()$ # create config(url = "https://me.shinyapps.io/myApp/")$ send("[email protected]") ## End(Not run)library(shiny) library(firebase) old <- options() options(shiny.port = 3000) ui <- fluidPage( useFirebase(), textInput("email", "Your email"), actionButton("submit", "Submit") ) server <- function(input, output){ f <- FirebaseEmailLink$ new()$ config(url = "http://127.0.0.1:3000") observeEvent(input$submit, { if(input$email == "") return() f$send(input$email) }) observeEvent(f$get_email_sent(), { sent <- f$get_email_sent() if(sent$success) showNotification("Email sent", type = "message") }) observeEvent(f$get_email_verification(), { print(f$get_email_verification()) }) } if(interactive()){ shinyApp(ui, server) } options(old) ## ------------------------------------------------ ## Method `FirebaseEmailLink$config` ## ------------------------------------------------ ## Not run: f <- FirebaseEmailLink$ new()$ # create config(url = "https://me.shinyapps.io/myApp/") ## End(Not run) ## ------------------------------------------------ ## Method `FirebaseEmailLink$send_email` ## ------------------------------------------------ ## Not run: f <- FirebaseEmailLink$ new()$ # create config(url = "https://me.shinyapps.io/myApp/")$ send("[email protected]") ## End(Not run)
Manage users using email and password.
An object of class FirebaseEmailPassword.
firebase::Firebase -> firebase::FirebaseAuth -> FirebaseEmailPassword
createdResults of account creation
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()new()
FirebaseEmailPassword$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialiases Firebase Email Password
Initialises the Firebase application client-side.
create()
FirebaseEmailPassword$create(email, password)
email, passwordCredentials as entered by the user.
Create an account
self
sign_in()
FirebaseEmailPassword$sign_in(email, password)
email, passwordCredentials as entered by the user.
Sign in with email
NULL if successful, the error otherwise.
get_created()
FirebaseEmailPassword$get_created()
Get account creation results
A list of length 2 containing success a boolean
indicating wherther creation was successful and response
containing the result of account creation or the error if failed.
reset_password()
FirebaseEmailPassword$reset_password(email = NULL)
emailEmail to send reset link to, if missing looks for current logged in user's email.
Reset user password
self
get_reset()
FirebaseEmailPassword$get_reset()
Get whether password reset email was successfully sent
A list of length 2 containing success a boolean
indicating whether email reset was successful and response
containing successful or the error.
send_verification_email()
FirebaseEmailPassword$send_verification_email()
Send the user a verification email
self
get_verification_email()
FirebaseEmailPassword$get_verification_email()
Get result of verification email sending procedure
A list of length 2 containing success a boolean
indicating whether email verification was successfully sent and response
containing successful or the error.
set_password()
FirebaseEmailPassword$set_password(password)
passwordThe authenticated user password, the user should be prompted to enter it.
Set user password
Useful to provide ability to change password.
self
get_password()
FirebaseEmailPassword$get_password()
Get response from set_password
A list of length 2 containing success a boolean
indicating whether setting password was successfully set and response
containing successful as string or the error.
re_authenticate()
FirebaseEmailPassword$re_authenticate(password)
passwordThe authenticated user password, the user should be prompted to enter it.
Re-authenticate the user.
Some security-sensitive actions—such as deleting an account, setting a primary email address, and changing a password—require that the user has recently signed in. If you perform one of these actions, and the user signed in too long ago, the action fails with an error.
self
get_re_authenticated()
FirebaseEmailPassword$get_re_authenticated()
Get response from re_authenticate
A list of length 2 containing success a boolean
indicating whether re-authentication was successful and response
containing successful as string or the error.
clone()
The objects of this class are cloneable with this method.
FirebaseEmailPassword$clone(deep = FALSE)
deepWhether to make a deep clone.
Also signs in the user if successful.
library(shiny) library(firebase) # modals register <- modalDialog( title = "Register", textInput("email_create", "Your email"), passwordInput("password_create", "Your password"), footer = actionButton("create", "Register") ) sign_in <- modalDialog( title = "Sign in", textInput("email_signin", "Your email"), passwordInput("password_signin", "Your password"), footer = actionButton("signin", "Sign in") ) ui <- fluidPage( useFirebase(), # import dependencies actionButton("register_modal", "Register"), actionButton("signin_modal", "Signin"), plotOutput("plot") ) server <- function(input, output){ f <- FirebaseEmailPassword$new() # open modals observeEvent(input$register_modal, { showModal(register) }) observeEvent(input$signin_modal, { showModal(sign_in) }) # create the user observeEvent(input$create, { f$create(input$email_create, input$password_create) }) # check if creation sucessful observeEvent(f$get_created(), { created <- f$get_created() if(created$success){ removeModal() showNotification("Account created!", type = "message") } else { showNotification("Error!", type = "error") } # print results to the console print(created) }) observeEvent(input$signin, { removeModal() f$sign_in(input$email_signin, input$password_signin) }) output$plot <- renderPlot({ f$req_sign_in() plot(cars) }) } ## Not run: shinyApp(ui, server)library(shiny) library(firebase) # modals register <- modalDialog( title = "Register", textInput("email_create", "Your email"), passwordInput("password_create", "Your password"), footer = actionButton("create", "Register") ) sign_in <- modalDialog( title = "Sign in", textInput("email_signin", "Your email"), passwordInput("password_signin", "Your password"), footer = actionButton("signin", "Sign in") ) ui <- fluidPage( useFirebase(), # import dependencies actionButton("register_modal", "Register"), actionButton("signin_modal", "Signin"), plotOutput("plot") ) server <- function(input, output){ f <- FirebaseEmailPassword$new() # open modals observeEvent(input$register_modal, { showModal(register) }) observeEvent(input$signin_modal, { showModal(sign_in) }) # create the user observeEvent(input$create, { f$create(input$email_create, input$password_create) }) # check if creation sucessful observeEvent(f$get_created(), { created <- f$get_created() if(created$success){ removeModal() showNotification("Account created!", type = "message") } else { showNotification("Error!", type = "error") } # print results to the console print(created) }) observeEvent(input$signin, { removeModal() f$sign_in(input$email_signin, input$password_signin) }) output$plot <- renderPlot({ f$req_sign_in() plot(cars) }) } ## Not run: shinyApp(ui, server)
Use OAuth provides such as Github or Facebook to allow users to conveniently sign in.
An object of class FirebaseOauthProviders.
firebase::Firebase -> firebase::FirebaseAuth -> FirebaseOauthProviders
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()new()
FirebaseOauthProviders$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialiases Firebase Email Link
Initialises the Firebase application client-side.
set_provider()
FirebaseOauthProviders$set_provider(provider, ...)
providerThe provider to user, e.g.: microsoft.com, yahoo.com or google.com.
...Additional options to pass to setCustomParameters.
Define provider to use
self
launch()
FirebaseOauthProviders$launch(
flow = c("popup", "redirect"),
get_credentials = FALSE
)flowAuthentication flow, either popup or redirect.
get_credentialsWhether to extract underlying oauth credentials.
Launch sign in with Google.
self
clone()
The objects of this class are cloneable with this method.
FirebaseOauthProviders$clone(deep = FALSE)
deepWhether to make a deep clone.
library(shiny) library(firebase) ui <- fluidPage( useFirebase(), actionButton("signin", "Sign in with Microsoft", icon = icon("microsoft")), plotOutput("plot") ) server <- function(input, output, session){ f <- FirebaseOauthProviders$ new()$ set_provider("microsoft.com") observeEvent(input$signin, { f$launch() }) output$plot <- renderPlot({ f$req_sign_in() plot(cars) }) } ## Not run: shinyApp(ui, server)library(shiny) library(firebase) ui <- fluidPage( useFirebase(), actionButton("signin", "Sign in with Microsoft", icon = icon("microsoft")), plotOutput("plot") ) server <- function(input, output, session){ f <- FirebaseOauthProviders$ new()$ set_provider("microsoft.com") observeEvent(input$signin, { f$launch() }) output$plot <- renderPlot({ f$req_sign_in() plot(cars) }) } ## Not run: shinyApp(ui, server)
Use mobile phone numbers to authenticate users.
An object of class FirebasePhone.
firebase::Firebase -> firebase::FirebaseAuth -> FirebasePhone
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()new()
FirebasePhone$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialiases Firebase Phone
Initialises the Firebase application client-side.
verify()
FirebasePhone$verify(number, id = NULL)
numberPhone number of the user.
idId of the button that triggers verification.
If this is NULL the user has to go through the recaptcha,
if not NULL is invisible.
Verify a phhone number
get_recaptcha()
FirebasePhone$get_recaptcha()
Results from the recaptcha
confirm()
FirebasePhone$confirm(code)
codeConfirmation code received by the user.
Confirm a code
get_verification()
FirebasePhone$get_verification()
Get Verification
A list with a boolean (success) indicating
whether the operation was successful and a response
contianing the response from Firebase.
get_confirmation()
FirebasePhone$get_confirmation()
Get Confirmation
A list with a boolean (success) indicating
whether the operation was successful and a response
contianing the response from Firebase.
clone()
The objects of this class are cloneable with this method.
FirebasePhone$clone(deep = FALSE)
deepWhether to make a deep clone.
Use social sites for authentication.
An object of class FirebaseSocial.
firebase::Firebase -> firebase::FirebaseAuth -> FirebaseSocial
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()new()
FirebaseSocial$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialiases Firebase Social
Initialises the Firebase application client-side.
set_scope()
FirebaseSocial$set_scope(scope)
scopeGoogle scope.
Define the scope to request from Google.
self
launch_google()
FirebaseSocial$launch_google(flow = c("popup", "redirect"))flowAuthentication flow, either popup or redirect.
Launch sign in with Google.
self
launch_github()
FirebaseSocial$launch_github(flow = c("popup", "redirect"))flowAuthentication flow, either popup or redirect.
Launch sign in with Github.
self
launch_facebook()
FirebaseSocial$launch_facebook(flow = c("popup", "redirect"))flowAuthentication flow, either popup or redirect.
Launch sign in with Facebook.
self
launch_twitter()
FirebaseSocial$launch_twitter(flow = c("popup", "redirect"))flowAuthentication flow, either popup or redirect.
Launch sign in with Facebook.
self
clone()
The objects of this class are cloneable with this method.
FirebaseSocial$clone(deep = FALSE)
deepWhether to make a deep clone.
library(shiny) library(firebase) # define signin signin <- modalDialog( title = "Login", actionButton("google", "Google", icon = icon("google"), class = "btn-danger"), actionButton("github", "Github", icon = icon("github")), footer = NULL ) ui <- fluidPage( useFirebase() ) server <- function(input, output) { showModal(signin) f <- FirebaseSocial$new() observeEvent(input$google, { f$launch_google() }) observeEvent(input$github, { f$launch_github() }) } ## Not run: shinyApp(ui, server)library(shiny) library(firebase) # define signin signin <- modalDialog( title = "Login", actionButton("google", "Google", icon = icon("google"), class = "btn-danger"), actionButton("github", "Github", icon = icon("github")), footer = NULL ) ui <- fluidPage( useFirebase() ) server <- function(input, output) { showModal(signin) f <- FirebaseSocial$new() observeEvent(input$google, { f$launch_google() }) observeEvent(input$github, { f$launch_github() }) } ## Not run: shinyApp(ui, server)
Use firebase to manage authentications.
An object of class FirebaseUI.
firebase::Firebase -> firebase::FirebaseAuth -> FirebaseUI
tos_urlURL to the Terms of Service page.
privacy_policy_urlThe URL to the Privacy Policy page.
firebase::Firebase$expose_app()firebase::FirebaseAuth$clear()firebase::FirebaseAuth$delete_user()firebase::FirebaseAuth$expose_auth()firebase::FirebaseAuth$get_access_token()firebase::FirebaseAuth$get_delete_user()firebase::FirebaseAuth$get_id_token()firebase::FirebaseAuth$get_sign_out()firebase::FirebaseAuth$get_signed_in()firebase::FirebaseAuth$get_signed_up()firebase::FirebaseAuth$is_signed_in()firebase::FirebaseAuth$print()firebase::FirebaseAuth$req_sign_in()firebase::FirebaseAuth$req_sign_out()firebase::FirebaseAuth$request_id_token()firebase::FirebaseAuth$set_language_code()firebase::FirebaseAuth$sign_out()new()
FirebaseUI$new(
persistence = c("session", "local", "memory"),
config_path = "firebase.rds",
language_code = NULL,
session = shiny::getDefaultReactiveDomain()
)persistenceHow the auth should persit: none, the user has to sign in at every visit,
session will only persist in current tab, local persist even when window is closed.
config_pathPath to the configuration file as created by firebase_config.
language_codeSets the language to use for the UI.
Supported languages are listed here.
Set to browser to use the default browser language of the user.
sessionA valid shiny session.
Initialiases Firebase UI
Initialises the Firebase application client-side.
set_providers()
FirebaseUI$set_providers( google = FALSE, facebook = FALSE, twitter = FALSE, github = FALSE, email = FALSE, email_link = FALSE, microsoft = FALSE, apple = FALSE, yahoo = FALSE, phone = FALSE, anonymous = FALSE )
google, facebook, twitter, github, email, email_link, microsoft, apple, yahoo, phone, anonymousSet to TRUE the providers you want to use, at least one.
Define signin and login providers.
self
set_tos_url()
FirebaseUI$set_tos_url(url)
urlURL to use.
Defines Tterms of Services URL
self
set_privacy_policy_url()
FirebaseUI$set_privacy_policy_url(url)
urlURL to use.
Defines Privacy Policy URL
self
launch()
FirebaseUI$launch(flow = c("popup", "redirect"), account_helper = FALSE)flowThe signin flow to use, popup or redirect.
account_helperWether to use accountchooser.com upon signing in or signing up with email, the user will be redirected to the accountchooser.com website and will be able to select one of their saved accounts. You can disable it by specifying the value below.
...Any other option to pass to Firebase UI.
Setup the signin form.
self
reset_password()
FirebaseUI$reset_password(email = NULL)
emailEmail to send reset link to, if missing looks for current logged in user's email
Reset user password
self
get_reset()
FirebaseUI$get_reset()
Get whether password reset email was successfully sent
A list of length 2 containing success a boolean
indicating whether email reset was successful and response
containing successful or the error.
send_verification_email()
FirebaseUI$send_verification_email()
Send the user a verification email
self
get_verification_email()
FirebaseUI$get_verification_email()
Get result of verification email sending procedure
A list of length 2 containing success a boolean
indicating whether email verification was successfully sent and response
containing successful or the error.
set_password()
FirebaseUI$set_password(password)
passwordThe authenticated user password, the user should be prompted to enter it.
Set user password
Useful to provide ability to change password.
self
get_password()
FirebaseUI$get_password()
Get response from set_password
A list of length 2 containing success a boolean
indicating whether setting password was successfully set and response
containing successful as string or the error.
re_authenticate()
FirebaseUI$re_authenticate(password)
passwordThe authenticated user password, the user should be prompted to enter it.
Re-authenticate the user.
Some security-sensitive actions—such as deleting an account, setting a primary email address, and changing a password—require that the user has recently signed in. If you perform one of these actions, and the user signed in too long ago, the action fails with an error.
get_re_authenticated()
FirebaseUI$get_re_authenticated()
Get response from re_authenticate
A list of length 2 containing success a boolean
indicating whether re-authentication was successful and response
containing successful as string or the error.
clone()
The objects of this class are cloneable with this method.
FirebaseUI$clone(deep = FALSE)
deepWhether to make a deep clone.
library(shiny) library(firebase) ui <- fluidPage( useFirebase(), # import dependencies firebaseUIContainer() # import UI ) server <- function(input, output){ f <- FirebaseUI$ new()$ # instantiate set_providers( # define providers email = TRUE, google = TRUE ) } ## Not run: shinyApp(ui, server)library(shiny) library(firebase) ui <- fluidPage( useFirebase(), # import dependencies firebaseUIContainer() # import UI ) server <- function(input, output){ f <- FirebaseUI$ new()$ # instantiate set_providers( # define providers email = TRUE, google = TRUE ) } ## Not run: shinyApp(ui, server)
Access Firebase Realtime Database
An object of class RealtimeDatabase.
new()
RealtimeDatabase$new( config_path = "firebase.rds", session = shiny::getDefaultReactiveDomain() )
config_pathPath to the configuration file as created by firebase_config.
sessionA valid shiny session.
Initialiases Firebase Storage
Initialises the Firebase Storage application client-side.
ref()
RealtimeDatabase$ref(path = NULL)
pathPath to the database full URL to file.
Reference
Creates a reference to a file or directory you want to operate on. Note that this reference persists, make sure you change it between operations.
Invisibly return the class instance.
on_value()
RealtimeDatabase$on_value(response, path = NULL)
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
pathPath to the database full URL to file.
On Value
When path or ref sees an update it sends the new
data to response.
set()
RealtimeDatabase$set(data, response = NULL, path = NULL)
dataDataset to upload.
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
pathPath to the database full URL to file.
Set Data
Pushes data to the database.
update()
RealtimeDatabase$update(data, response = NULL, path = NULL)
dataDataset to update.
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
pathPath to the database full URL to file.
Update Data
Update a record.
delete()
RealtimeDatabase$delete(response = NULL, path = NULL)
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
pathPath to the database full URL to file.
Delete
Delete data to the database.
clone()
The objects of this class are cloneable with this method.
RealtimeDatabase$clone(deep = FALSE)
deepWhether to make a deep clone.
Add the recaptcha, require for the FirebasePhone
class.
recaptchaUI( ns = function(x) { x } )recaptchaUI( ns = function(x) { x } )
ns |
Namespace, optional, only required if using this function in multiple places. |
Define UI element that require the user to be signed in. This will hide them viusally until the user signs in. Note that this is not secure as someone can easily change the CSS when visiting the page to reveal those elements.
reqSignin(...)reqSignin(...)
... |
Any valid tags. |
No return value, called for side effects.
Define UI element that requires no user to be signed in. This will hide them viusally if no user is signed in. Note that this is not secure as someone can easily change the CSS when visiting the page to reveal those elements.
reqSignout(...)reqSignout(...)
... |
Any valid tags. |
Storage
Storage
An object of class Storage.
firebase::Firebase -> Storage
new()
Storage$new( config_path = "firebase.rds", session = shiny::getDefaultReactiveDomain() )
config_pathPath to the configuration file as created by firebase_config.
sessionA valid shiny session.
Initialiases Firebase Storage
Initialises the Firebase Storage application client-side.
ref()
Storage$ref(path = NULL)
pathPath to the file, directory, bucket, or
full URL to file.
If NULL creates a path to the root.
Reference
Creates a reference to a file or directory you want to operate on. Note that this reference persists, make sure you change it between operations.
Invisibly return the class instance.
upload_file()
Storage$upload_file(file, response = TRUE)
filePath to the file to upload.
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
Upload a File
Upload a file to the store system or bucket. Requires a valid authentication.
\dontrun{
s <- Storage$new()
# default response
s$
ref("test.png")$
upload_file("path/to/file.png")
observeEvent(s$get_response(), {
# do something
})
# named response
s$
ref("test.png")$
upload_file("path/to/file.png", response = "fl")
observeEvent(s$get_response("fl"), {
# do something
})
}
download_file()
Storage$download_file(response = TRUE)
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
Download a File
Download a file from the store system or bucket. Requires a valid authentication.
\dontrun{
s <- Storage$new()
s$
ref("test.png")$
upload_file("path/to/file.png")$
download_file("dl")
observeEvent(s$get_response("dl"), {
# do something
})
}
delete_file()
Storage$delete_file(response = TRUE)
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
Delete a File
Delete a file from the store system or bucket. Requires a valid authentication.
get_metadata()
Storage$get_metadata(response = TRUE)
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. FALSE indicates you do
not want those results back. A character string is
used as named of the response which then can be used
in the get_response method.
File Metadata
Get the metadata of a file from the store system or bucket. Requires a valid authentication.
list_files_all()
Storage$list_files_all(response = TRUE)
responseA boolean or character string.
TRUE indicates that you want to capture the
results of the file upload (e.g.: success or failed)
with get_response method. A character string is
used as named of the response which then can be used
in the get_response method.
List All Files
List all files in the reference (ref).
Requires a valid authentication.
get_response()
Storage$get_response(response = NULL)
responseName of the response.
Capture response
clone()
The objects of this class are cloneable with this method.
Storage$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------ ## Method `Storage$upload_file` ## ------------------------------------------------ ## Not run: s <- Storage$new() # default response s$ ref("test.png")$ upload_file("path/to/file.png") observeEvent(s$get_response(), { # do something }) # named response s$ ref("test.png")$ upload_file("path/to/file.png", response = "fl") observeEvent(s$get_response("fl"), { # do something }) ## End(Not run) ## ------------------------------------------------ ## Method `Storage$download_file` ## ------------------------------------------------ ## Not run: s <- Storage$new() s$ ref("test.png")$ upload_file("path/to/file.png")$ download_file("dl") observeEvent(s$get_response("dl"), { # do something }) ## End(Not run)## ------------------------------------------------ ## Method `Storage$upload_file` ## ------------------------------------------------ ## Not run: s <- Storage$new() # default response s$ ref("test.png")$ upload_file("path/to/file.png") observeEvent(s$get_response(), { # do something }) # named response s$ ref("test.png")$ upload_file("path/to/file.png", response = "fl") observeEvent(s$get_response("fl"), { # do something }) ## End(Not run) ## ------------------------------------------------ ## Method `Storage$download_file` ## ------------------------------------------------ ## Not run: s <- Storage$new() s$ ref("test.png")$ upload_file("path/to/file.png")$ download_file("dl") observeEvent(s$get_response("dl"), { # do something }) ## End(Not run)