【问题标题】:Google plus Native plugin with webClientId带有 webClientId 的 Google plus Native 插件
【发布时间】:2017-07-19 05:52:13
【问题描述】:

我在 Ionic 3 应用中使用 native Google Plus 插件。

Login()方法是这样的:

login(){

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

    }

这里的问题是关于webClientId。因此我在开发者控制台(iOS 和Android)上创建了2 个应用程序,它显示了2 个不同的webClientIds。那么我应该为上面的代码赋予哪个值?

【问题讨论】:

  • 您要获取idToken 还是serverAuthCode?还是只是简单的用户身份验证?
  • 不要删除答案。我会测试并通知你。我正在等待我的后端开发人员的反馈。之后,我会给你一个反馈。我想,对于我的简单用例,您的答案是正确的。 @SwapnilPatwa
  • 好的,我以为我错过了idToken 部分并感到困惑。

标签: android ios ionic2 google-plus ionic3


【解决方案1】:

有用的链接: Ionic Google Authentication

插件链接:enter link description here

您无需将 webClientId 放入GooglePlus.login()

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

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

iOS

对于 iOS,您需要将 REVERSED_CLIENT_ID 放入 config.xml

<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

安卓

对于 android,您不需要任何 id,它适用于 Signing-certificate fingerprint,确保 Signing-certificate fingerprintPackage name 在创建 oauth client id 时正确。

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

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

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

【讨论】:

  • 其实我需要为Android设置。你提到iOS没有?
  • 是的,仅此而已。你知道这条路径是什么keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore。这条路径~/.android/debug.keystore吗?
  • OK。希望我可以使用此命令在我的 android 设备上进行测试,不是吗?完成以上所有操作后。 ionic cordova run android --device
  • 您的 cmd 上似乎有错字没有? '--prod'?
  • 不,它会让你的应用程序更快,特别是在启动时。试试看。
猜你喜欢
  • 1970-01-01
  • 2018-12-18
  • 2018-11-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-27
  • 1970-01-01
  • 2018-03-06
  • 2017-03-13
相关资源
最近更新 更多