Home > Software engineering >  google social login not working in ionic capacitor using codetrix-studio capacitor-google-auth
google social login not working in ionic capacitor using codetrix-studio capacitor-google-auth

Time:11-10

in the capacitor.config.json

"GoogleAuth": {
  "scopes": ["profile","email"],
  "serverClientId": "KEY.apps.googleusercontent.com"
}

in index.html

<meta name="google-signin-client_id" content="KEY.apps.googleusercontent.com">

in android folder string.xml file

<string name="server_client_id">KEY.apps.googleusercontent.com</string>

and in our page .ts file to get detail of google user detail

const user = await GoogleAuth.signIn();

and I have an error in android something went wrong.

anyone has any idea how to solve this situation

CodePudding user response:

You have to add these lines of code in android/app/src/main/java/com/appName/app/MainActivity.java

package com.growyd.app;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;
import com.getcapacitor.Plugin;

import java.util.ArrayList;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    //Initialize bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      add(GoogleAuth.class);
    }});
  }
}

In this link are the steps to configure the library.

my reference: https://devdactic.com/capacitor-google-sign-in/

  • Related