首页 > 解决方案 > 离子谷歌登录在 android 上工作但在 IOS 上工作:有效负载观众!= requiredAudience

问题描述

我一直在使用这个插件在 ionic 中开发谷歌登录功能: https ://github.com/EddyVerbruggen/cordova-plugin-googleplus

这已经是一段痛苦的旅程。我现在可以在android上运行。我要求插件向我传递一个 idToken,但为了检索它,您需要将 webClientId 与它一起传递(如下面的代码所示)。我从 android 和 ios 中检索到该 idToken 并将其发送到后端以检查它是否是真正的令牌。现在这是我不太明白的部分。在 android 上,验证通过并登录用户,但在 ios 上,如果给我错误wrong recipient, payload audience != requiredAudience

代码完全相同,所以我不太明白这里发生了什么。有没有人对此有任何经验以及可以帮助我的插件?提前一百万谢谢。如果这可以帮助任何人,这是代码:

googleLogin() {
        this.isLoggingIn = true;

        this.googlePlus.login({
            'webClientId': environment.webClientId
        }).then(googleRes => {
            this.authService.googleLogin(googleRes.idToken).subscribe(
            //logic
            )
        }).catch(err => {
            console.log(err);
            this.isLoggingIn = false;
        });
    }

标签: androidiosionic-frameworkgoogle-signin

解决方案


推荐阅读