How to Migrate from accountKit to Firebase Phone sign up? - node.js

I'm using AccountKit for phone sign up right now in our mobile app. As AccountKit will be deprecated soon so we are migrating with firebase phone sign up.
I have set up a new user/Sign-up flow but still confused about old users when they log-in again using a new sign-in method(Firebase).
Current Login Process:
Client request with the access token.
Server request to account kit with an access token and get user data with UID
By this UID I check in current database user present or not.
Problem:
When old user tries to sign in through firebase then I'll get different UID(UID of firebase) which is not present in my database so it will consider it as a new user.
Backend: Node js
Can someone help me what would be the best approach to migrate?

Related

Integrate Both Google Sign In and Local sign-In in web app

I am creating a web app and i want to be able to register users local through a registeration form which will have a password form as well. But i also want users to be registered to through GOOGLE SIGNIN api. Problem is in my database the password field is required. Is there a possible logic to store users that registered with google in the db without getting errors because google wont provide a password for them to the db?
I am Using Node Express js for server and Mongodb for database

Persistent Login with Spotify Web API using MERN stack

So I have a web app using the MERN stack, and it contains a user database allowing people to register and login to an account. I want to integrate the Spotify API, but I want a user to only to have to connect to Spotify once.
I want it so that a user logs in they have an option to connect to Spotify, and then once they have authenticated it will display some info. I am thinking maybe I need to make a different page and have something set up like
if (userIsLoggedIntoSpotify){
<Link to="/newpage"></Link>
}
I also want it so that if a user logs into the app on another computer and they already authenticated they do not have to authenticate again.
I currently have an app that users can register, login and out, and I have a working authentication link to Spotify, I just need a way to tell if users have already authenticated and if so maybe automatically send them to a new page that has the Spotify API already set up and displaying data.
The best way to do that would be to use the Authorization Code Flow with your current user setup. Your app will need to save the Spotify data (access_token and refresh_token) to your database. One way would be a user would have to first create an account with your app and then they could connect their Spotify account to your app. That way you can save the access_token and refresh_token on the user object to use later.
When the user logs in later or on a different device, your app would grab the access_token and refresh_token from your apps database to do whatever you need. As a small note, the access_token expires every 60 minutes so you will need the refresh_token to request a new access_token. When the user logs in at a later time, it will need to check if the access_token is expired or not.

Automatically get Google OAuth2 token with cloud printing permissions if username and password is already known

I have a firebase app, everytime any user makes a suspicious movement, it needs to be printed. I'm trying to write a trigger on the server that can access cloud printing via the username "printerXXX#gmail.com" password "xxxx" that I have.
The google cloud printing needs an OAuth2 token in the authorization heading to access its printers. I'm trying to use googleapi node.js package to get the access token. However this means that I need a web front end, to tick "give googleappXXX permission to my cloud printers". Is it possible to do everything in the backend if I already have the password and email?

Authenticate user without using angularfire

I am working on an application in which i need to authenticate user. I am using firebase for database. I have used node.js for getting data from firebase. Now all i want is to create login page and in that i need to authenticate user by their email address and password. And i want to use the same method how i am fetching the data that is using node and i don't want to use angularfire for the authentication. Is it possible to perform? If it is can you please share how can i accomplish that?
Authenticating from a server-side process with the Firebase 3.x SDK requires the use of a service account. From the documentation:
When you authenticate a server, rather than sign in with a user account's credentials as you would in a client app, you authenticate with a service account which identifies your server to Firebase.
If you want to custom handle the authentication of your users, you'd create a custom token for your users on the server and then have them pass that to Firebase.
In general I'd recommend reading this article about common application architectures when using the Firebase Database.

Firebase create entry when user signs in

I am trying to setup a login process for firebase. I am going to be using client side user creation (because apparently firebase only allows client side user creation), and here's what my workflow looks like:
User signs up through email and password
Service creates an entry at /users/$uid, as well as a couple others (ie /table1/$uid, /table2/$uid)
User can write to database at path /users/$uid, /table1/$uid, etc where $uid = the current logged in user (this is done via rules)
However, for number 2, I want to create the entry /users/$uid, but I dont want the user to have access to that at all. Is there any way to do this? One option I thought of was having a service account running with all r/w permissions on a node server to create those tables, but how would I call that server method if I'm doing all of the auth client side?
After step #1,
Your client code can get a Firebase token for the current login user via firebase.user.getToken()
Your client app sends the token to your node server
The node server validates the token using Firebase server SDK
The server extracts user id from token.uid.
Now you can continue step #2 to create table for the user.

Resources