JohnCoene / firebase

Google FIrebase for shiny
https://firebase.john-coene.com
GNU Affero General Public License v3.0
170 stars 26 forks source link

Wordpress connection #58

Open ugurdar opened 1 year ago

ugurdar commented 1 year ago

Hi there,

I'm using firebase on my website. I have a button to redirect user to my shinyapp.

My problem is, user should login two time, 1. in website, 2. in app.

I wonder that is there any way to user login ones?

Thank you!

JohnCoene commented 1 year ago

If the website and the app share the same Firebase project they will only have to login once, in either place. That's one of the features of firebase.

ugurdar commented 1 year ago

website and app sharing same Firebase project and I created config file following this way:

firebase::firebase_config(
    api_key = "my-api-key", 
    project_id = "my-project-id"
)
JohnCoene commented 1 year ago

But what is the problem exactly?

ugurdar commented 1 year ago

In my wordpress website, when user logged in, can see the "Application" button. When clicked on the button, user see another page and there is Shiny app but should login one more time. My problem is when user login in wordpress and click on Application button and come to Shiny app page i want to be able to access app directly instead of logging in again.

Do i need to handle this problem on wordpress side? Or can I generate a token when the user clicks this button and capture it using the Shiny firebase package?

Sorry if I'm asking a weird question, I'm very new to this wordpress and firebase stuff :/

JohnCoene commented 1 year ago

Firebase (and most auth services) will keep you signed in only on the same domain. So if users sign in on on wordpress at mysite.com then go the app at app.mysite.com it will keep them sign in but if they go to anothersite.com it will not.

ugurdar commented 1 year ago

mysite.com -> app.mysite.com I'm following this but I hosted my app on app.fly.io with a docker container and directed to app.mysite.com I guess problem is here.

I thought this solution, when user click on the button it will create a token and save it in a database and redirect user with a app.myiste.com/?user_email=user@email&token=$token then Shiny app firstly control the database if user and token matched won't show firebase ui.

JohnCoene commented 1 year ago

That's strange it should work, not sure how the app is hosted is it on your actual domain or does it redirect?

ugurdar commented 1 year ago

I'm using fly.io server, I dockerized my app and hosted as myapp.fly.io and redirect to myapp.mysite.com

JohnCoene commented 1 year ago

Make sure you have authorised the domain on firebase console maybe

ugurdar commented 1 year ago

I authorised, I can login when I type my mail and password at myapp.mysite.com.

I don't how how actually it's work but is it possible to getting a login token from Firebase? and is the package allows getting that tokens before app start?

WP Sending Firebase Token to myapp.mysite.com with a query -> app observering token if token exist allows user.