首页 文章

Android设备上的离子原生googleplus登录问题(离子2)

提问于
浏览
1

我想在我的应用程序中集成g登录 . 我按照以下步骤操作:

首先,使用以下命令安装ionic-navtive gplus插件: ionic plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid

使用从 console.developers.google.com 生成的反向客户端ID . 其格式为 xxxxxxxx-xxxxxxxxx.apps.googleusercontent.com .

然后单击登录按钮尝试g本机呼叫 . 这是我的ts代码:

googleLogin() {
    this.googlePlus.login({
      'webClintId':'xxxxxxxx-xxxxxxxxx.apps.googleusercontent.com ',
    }).then((res) => {
      alert("Login successfull: " + res);
      this.navCtrl.setRoot(HomePage);
    }).catch((err) => {
      alert("Login unsuccessfull: " + err);
    });
}

在尝试上面的代码时,它将进入错误块和打印:

登录失败:17

我跟着:https://ionicthemes.com/tutorials/about/ionic2-google-login

1 回答

  • 1

    您不需要将webClientId放在 GooglePlus.login() 中 .

    您的登录方法应该是(如果没有其他选项) -

    GooglePlus.login({}).then((res) => {
        console.log(res);
    }, (err) => {
        console.log(err);
    });
    

    iOS

    你需要在 config.xml 中放置 REVERSED_CLIENT_ID for iOS .

    <plugin name="cordova-plugin-googleplus" spec="~5.1.1">
            <variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.967272422526-vu37jlptokv45glo2kciu9o2rddm7gte" />
    </plugin>
    

    要找到您 REVERSED_CLIENT_ID ,请在开发人员控制台中转到凭据,然后单击已创建的iOS凭据和 Download Plist .

    enter image description here

    Android

    对于Android你不需要任何id,它适用于 Signing-certificate fingerprint ,确保你在创建 oauth client idSigning-certificate fingerprintPackage name 是正确的 .

    enter image description here

    如果您没有使用任何创建的密钥库文件对apk进行签名,请使用 SHA-1 signing-certificate fingerprint 的默认debug.keystore文件 .

    keytool -exportcert -keystore C:\Users\Username\.android\debug.keystore -list -v
    

    我使用了最常见的 debug.keystore (windows)路径 . 对你来说可能有所不同,只需寻找 .android dir .

相关问题