一、接入准备
- 手机必须有Google套件
Google服务框架,Google Play商店,Google Play服务(使用su谷歌安装器下载安装) - 手机必须可以翻墙
- google开发者账号
二、官网文档
https://developers.google.com/identity/sign-in/android/start-integrating?hl=zh-cn
三、接入步骤
- 依赖google play服务
implementation 'com.google.android.gms:play-services-auth:20.2.0'
-
配置 Google API 控制台项目
需要使用google开发者账号,创建项目,在项目中根据包名和SHA1值创建应用。
控制台: https://console.cloud.google.com/apis/credentials?hl=zh-cn -
代码
3.1 获取GoogleSignInClient 对象
private final String TAG = getClass().getSimpleName();
/**
* google登录客户端对象
*/
private GoogleSignInClient mGoogleSignInClient;
private void initGoogleSignInClient() {
// C