Android-GoogleSignIn与AWS-AmplifyCognito不像预期的那样工作
创始人
2024-08-19 18:30:24
0
  1. 确认已正确添加Google SignIn和AWS-Amplify Cognito依赖项到Android项目中。
  2. 确保在AWS Console中正确配置了Cognito和Google身份验证。
  3. 在Android项目的build.gradle文件中添加以下依赖项:

dependencies { implementation 'com.amazonaws:aws-android-sdk-auth-userpools:2.28.+' implementation 'com.amazonaws:aws-android-sdk-auth-ui:2.28.+' implementation 'com.amazonaws:aws-android-sdk-cognito:2.28.+' implementation 'com.google.android.gms:play-services-auth:19.2.0' }

  1. 在MainActivity.java文件中添加以下代码:

public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener {

private GoogleApiClient googleApiClient;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Build Google Sign In client
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();

    googleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    // Set click listeners
    findViewById(R.id.sign_in_button).setOnClickListener(this);
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.e(TAG, "onConnectionFailed:" + connectionResult);
}

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.sign_in_button:
            signIn();
            break;
    }
}

private void signIn() {
    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
    startActivityForResult(signInIntent, RC_SIGN_IN);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);

相关内容

热门资讯

实测交流!hhpoker是真的... 实测交流!hhpoker是真的还是假的,菠萝辅助器免费版的特点,安装教程(有挂方法)科技教程也叫必备...
玩家必看科普!德普之星app安... 此外,数据分析德州(德普之星app安卓版破解版)辅助神器app还具备辅助透视行为开挂功能,通过对客户...
记者揭秘!aapoker发牌逻... 记者揭秘!aapoker发牌逻辑,哈糖大菠萝软件下载,可靠技巧(有挂透视);1分钟了解详细教程(微信...
大家学习交流!wepoker线... 大家学习交流!wepoker线上大神,wpk私人辅助,科技教程(有挂方法)1、点击下载安装,微扑克w...
必备攻略!wepoker智能辅... 必备攻略!wepoker智能辅助插件,wepoker辅助透视,2025新版教程(有挂攻略);原来确实...
玩家必备教程!wepoker国... 玩家必备教程!wepoker国外版透视,wepoker怎么挂底牌,解密教程(有挂辅助);人气非常高,...
重大发现!wepoker新号好... 1、重大发现!wepoker新号好一点吗,wepokerplus辅助,详细教程(有挂辅助)(UU p...
专业讨论!wepoker怎么获... 此外,数据分析德州(wepoker辅助器软件下载)辅助神器app还具备辅助透视行为开挂功能,通过对客...
必备攻略!wepoker国外版... 必备攻略!wepoker国外版透视,wepoker透视底牌,介绍教程(有挂攻略)科技教程也叫必备教程...
一分钟了解!wpk刷入池率脚本... 一分钟了解!wpk刷入池率脚本,大菠萝辅助器,必赢方法(有挂透明);wpk刷入池率脚本软件透明挂更新...