我在使用与我们网站共享的API对话的Ionic应用程序中遇到了使用Google Plus身份验证插件的问题。
在Google控制台中,我有三个OAuth 2.0客户端ID,例如给出的ID:
- Android客户端(由Google服务自动创建)1.apps.google
- iOS客户端(由Google服务自动创建)2.apps.google
- Webapp 3.app.googles
它们都以相同的12位数字开头,并以“apps.googleusercontent.com”结尾。
根据Google的文档,我应该能够通过添加标识API客户端ID的范围设置来对移动应用程序和网站进行身份验证。 例如: _scope:audience:server:client_id:3.apps.google_
this.googlePlus.login({
'webClientId': '2.apps.google',
'scope': 'scope:audience:server:client_id:3.apps.google'
})
我已经能够从Google获取JWT,但是当我解码它时,我发现aud值与我的webClientId设置匹配,而不是来自scope的值。就我所知,唯一一个持久保存客户端ID(即不被Ionic创建的.gitignore文件排除)的地方是config.xml。
<plugin name="cordova-plugin-googleplus" spec="git+https://github.com/EddyVerbruggen/cordova-plugin-googleplus.git">
<variable name="REVERSED_CLIENT_ID" value="google.apps.2" />
</plugin>
和 package.json 文件
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "google.apps.2"
}
那么,我要把哪些客户端ID放在哪里,才能使我的移动应用程序针对与我们的网站使用相同的API进行用户身份验证?