Authentication on G Suite domain/scope

3,558 views
Skip to first unread message

Kai Hendry

unread,
Oct 27, 2016, 11:19:51 AM10/27/16
to Firebase Google Group
Hi there,


Nonetheless, I'm taking a quick look at Firebase and wondering if I can solve my problem.

We use G suite at work, lets call the domain @example.com.

I want to only allow @example.com / employees to use my "serverless" JS app. Is this called a scope? I got a bit lost upon https://developers.google.com/identity/protocols/googlescopes


Thank you!

Jacob Wenger

unread,
Oct 27, 2016, 1:08:52 PM10/27/16
to fireba...@googlegroups.com
Hey Kai,

You are in luck since this feature was actually just recently added! You can do this via the setCustomParameters() method. Check out step three in the instructions here. Instead of login_hint, you'll want to use hd (short for "hosted domain"). The full list of available parameters is here. To limit sign-ins to @example.com Google accounts, your code would look something like this:

var provider = new firebase.auth.GoogleAuthProvider();
provider.setCustomParameters({
  hd: "example.com"
});

firebase.auth().signInWithPopup(provider)
  .then(function(result) {
    // This gives you a Google Access Token. You can use it to access the Google API.
    var token = result.credential.accessToken;

    // The signed-in user info.
    var user = result.user;

    // ...
  })
  .catch(function(error) {
    console.log("Error signing in:", error);
  });

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c6ed3096-8e96-4543-b68b-9ae85056f800%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Quentin Veyret

unread,
Oct 28, 2016, 10:52:50 AM10/28/16
to Firebase Google Group
Hi Jacob,

Thank you for this very useful feature!

Is there a way to specify more than one domain?
For example if a customer has multiple domains but only wants to allow the login to a few of them.

Thanks for your help.

Best regards,
Quentin
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Jacob Wenger

unread,
Oct 28, 2016, 8:53:10 PM10/28/16
to fireba...@googlegroups.com
Hey Quentin,

I'm not aware of a way to specify multiple domains, but some quick Google searching did find some other people working around this particular issue. Might not work for your use case, but worth the shot.

Cheers,
Jacob

To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Quentin Veyret

unread,
Oct 30, 2016, 10:49:53 AM10/30/16
to Firebase Google Group
Hi Jacob,

Thank you for your help, multiple login possibilities could be a solution indeed, I will try it.

Anyway, checking the domain on the serverside is still a good solution (is the application is not serverless as Kai asked).

Best,
Quentin

Nikos Kermanidis

unread,
Apr 12, 2017, 12:27:31 PM4/12/17
to Firebase Google Group
Hi Jacob,

Can I do the same with the Android SDK? I couldn't find the setCustomParameters() method.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

Steve McNiven-Scott

unread,
May 24, 2017, 2:28:00 PM5/24/17
to Firebase Google Group
I would also be curious about iOS custom parameters, I don't see anything documented...?

Bassam

unread,
May 24, 2017, 7:20:15 PM5/24/17
to Firebase Google Group
Hey folks, there is no signInWithPopup/Redirect in Android/iOS. You would usually use the native Google sign in SDK to get the OAuth credential before calling signInWithCredential. You would need to pass the custom OAuth parameter for hd or login_hint from there if possible.

Bassam

Steve McNiven-Scott

unread,
Jun 5, 2017, 3:17:54 PM6/5/17
to Firebase Google Group
@Bassam
Any chance of pointing at the docs?  I've gone though them and I just can't find any reference to set the params?

Steve

Steve McNiven-Scott

unread,
Jun 5, 2017, 4:04:26 PM6/5/17
to Firebase Google Group
OH HO!  I see I think... I poked into the code for the firebase plugin I'm using and yeah it's using core google libs.

So I think this is what we need
 setHostedDomain builder method on Android, and the hostedDomain property on iOS.

Steve
Reply all
Reply to author
Forward
0 new messages