Mr. Robot
Mr. Robot

Reputation: 1834

ConnectyCube with React Native / Firebase /Google Auth

I have an app that uses Google auth with Firebase and React Native. Can I use the google authentication for user management and session creation with ConnectyCube?

The ConnectyCube docs describe Firebase account and project registration but don't explain how that relates to the ConnectyCube API.

Also in the ConnectyCube docs it give details the Create session with User authorization parameters and providers as Possible values: facebook, twitter, firebase_phone, but not google. Any help appreciated.

Upvotes: 0

Views: 236

Answers (1)

Erik Rybalkin
Erik Rybalkin

Reputation: 1251

Since you have already set up an authentication system with Firebase, you probably do not need to use ConnectyCube authentication module to manage passwords and users.
At least in my case, we do not need that functionality but we still must login to ConnectyCube to use their services.

After the user logs in, we can subscribe to one's state and retrieve the user object:

     async function onAuthStateChanged(user) {
      // we do different operations here

         await connectyCube.configure(user);
     } 

     useEffect(() => {
       const subscriber = auth().onAuthStateChanged(onAuthStateChanged);
       return subscriber; // unsubscribe on unmount
     }, []);

In ConnectyCube.js:

configure = async user => {
/*
Here you can:
Do session login
check for the active session
Format the user
Try Catch different scenarios
Sign up a user
Check if a user exists
*/
   ConnectyCube.users
    .signup(user)
    .then(user => {
      console.log('[ConnectyCube.users signup]', user);
    })
    .catch(error => {
      console.log(`%c[ConnectyCube.users signup] ${error}`, 'color: red');
    });
};

Hope it gives some ideas

Upvotes: 0

Related Questions