如何让 Firebase 身份验证 OAuthProvider 使用 OIDC 提供程序添加其他范围

joe*_*4no 6 firebase angularfire openid-connect firebase-authentication google-identity

我已将自定义 OIDC 提供商添加到我的 Google Identity Platform。我可以成功地通过它进行身份验证,所以我知道这不是提供程序配置的问题,但由于某种原因,当我尝试向令牌请求添加其他范围时,新范围不会出现在请求 url 中。在下面的代码块中,我看到 OAuthProvider 对象显示了我在请求 signInWithPopup 之前添加的其他范围。但在此请求之后,当我验证收到的令牌时,它仅具有“oidc”范围,并且其他范围不会出现在弹出窗口的 URL 中。我是否缺少一些额外的步骤,或者其他范围是否不适用于 Firebase Auth 中的自定义 OIDC 提供商?

    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
Run Code Online (Sandbox Code Playgroud)

在我必须进行自己的身份验证之前,我们将不胜感激任何帮助或确认。谢谢,

Ale*_*sen 0

使用重定向。

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);
Run Code Online (Sandbox Code Playgroud)

使用弹出窗口。

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;
});
Run Code Online (Sandbox Code Playgroud)