6

I have added a custom OIDC Provider to my Google Identity Platform. I can successfully authenticate with it, so I know it's not an issue with the provider configs, but for some reason when I try to add additional scopes to the token request the new scopes do not appear in the request url. In the code block below, I see the OAuthProvider object showing the additional scopes I added before requesting the signInWithPopup. But after this request when I validate the token I received it only has the 'oidc` scope and the additional scopes do not appear in the URL of the popup. Am I missing some additional step or does additional scopes not work with custom OIDC providers in Firebase Auth?

    let twitch = new firebase.auth.OAuthProvider('oidc.twitch');
    twitch.addScope('moderation:read');
    twitch.addScope('user:edit');
    console.log(twitch); // This shows the additional scopes requested
    const user = await this.auth.signInWithPopup(twitch); // This URL only shows the oidc scope
    console.log(user); // This user token does not have any additional scopes

Any help or confirmation is appreciated before I have to go roll my own auth. Thanks,

joed4no
  • 1,243
  • 13
  • 17

2 Answers2

0

Using a redirect.

firebase.auth().getRedirectResult().then(function(result) {
  if (result.credential) {
    // This gives you the OAuth Access Token for that provider.
    var token = result.credential.accessToken;
  }
  var user = result.user;
});

// Start a sign in process for an unauthenticated user.
var provider = new firebase.auth.OAuthProvider('google.com');
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithRedirect(provider);

Using a popup.

var provider = new firebase.auth.OAuthProvider('google.com');
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithPopup(provider).then(function(result) {
 // This gives you the OAuth Access Token for that provider.
 var token = result.credential.accessToken;
 // The signed-in user info.
 var user = result.user;
});
0

It seems Google Identity Platform only pass defined scopes in openid-configuration scopes_supported field. But I think, it should not be like that to provide functionality

{
 ...
 "scopes_supported": [
  "openid",
  "email",
  "profile"
 ],
 ...
}

Examples: