firebase / firebaseui-web-react

React Wrapper for firebaseUI Web
Apache License 2.0
1.26k stars 249 forks source link

Can't access firebaseui library to set AnonymousAuthProvider #45

Closed mbbender closed 6 years ago

mbbender commented 6 years ago

How can you get access to the underlying firebaseui instance? I tried a handful of options but thing seems to work. I'd like to set the AnonymousAuthProvider option.

nicolasgarnier commented 6 years ago

Following the examples in the README didn't work for you? For instance, see the AnonymousAuthProvider below the GoogleAuthProvider:

// Import FirebaseAuth and firebase.
import React from 'react';
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import firebase from 'firebase';

// Configure Firebase.
const config = {
  apiKey: 'AIzaSyAeue-AsYu76MMQlTOM-KlbYBlusW9c1FM',
  authDomain: 'myproject-1234.firebaseapp.com',
  // ...
};
firebase.initializeApp(config);

// Configure FirebaseUI.
const uiConfig = {
  // Popup signin flow rather than redirect flow.
  signInFlow: 'popup',
  // Redirect to /signedIn after sign in is successful. Alternatively you can provide a callbacks.signInSuccess function.
  signInSuccessUrl: '/signedIn',
  // We will display Google and Facebook as auth providers.
  signInOptions: [
    firebase.auth.GoogleAuthProvider.PROVIDER_ID,
    firebase.auth.AnonymousAuthProvider.PROVIDER_ID
  ]
};

class SignInScreen extends React.Component {
  render() {
    return (
      <div>
        <h1>My App</h1>
        <p>Please sign-in:</p>
        <StyledFirebaseAuth uiConfig={uiConfig} firebaseAuth={firebase.auth()}/>
      </div>
    );
  }
}
nicolasgarnier commented 6 years ago

Closing but let me know if you still had issues.

JemarJones commented 4 years ago

I believe i had a similar issue. Using typescript and wasn't able to use firebase.auth.AnonymousAuthProvider.PROVIDER_ID because AnonymousAuthProvider isn't available on the firebase.auth object, even when tsignoring the type, so it really wasn't there.

Instead i had to do

import { auth as firebaseuiAuth } from 'firebaseui';
...
  signInOptions: [
    firebase.auth.GoogleAuthProvider.PROVIDER_ID,
    firebase.auth.FacebookAuthProvider.PROVIDER_ID,
    firebase.auth.EmailAuthProvider.PROVIDER_ID,
    firebaseuiAuth.AnonymousAuthProvider.PROVIDER_ID,
  ],

works but pretty weird ?

vzayko commented 4 years ago

Is this issue scheduled for fix some day?

chidexebere commented 1 year ago

...weird ....4 years now and this issue persists

jmmrte commented 9 months ago

@JemarJones Life saver. Thanks!