Android (v3) unable to process google auth intent #4431
-
I'm trying to get Google Sign In plugin working, but am failing at callback stage, with following error (using @capacitor/core 3.0.0-rc.0)
From what I saw in the docs Full plugin code below package com.my.project;
import android.content.Intent;
import androidx.activity.result.ActivityResult;
import com.getcapacitor.JSObject;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.annotation.ActivityCallback;
import com.getcapacitor.annotation.CapacitorPlugin;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.Task;
@CapacitorPlugin(name = "GoogleAuth")
public class GoogleAuth extends Plugin {
private GoogleSignInClient googleSignInClient;
@Override
public void load() {
String clientId = getContext().getResources().getString(R.string.google_client_id);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(clientId)
.requestEmail()
.build();
googleSignInClient = GoogleSignIn.getClient(this.getContext(), gso);
}
@PluginMethod()
public void signIn(PluginCall call) {
Intent signInIntent = googleSignInClient.getSignInIntent();
startActivityForResult(call, signInIntent, "onSignInResult");
}
@PluginMethod()
public void signOut(PluginCall call) {
googleSignInClient.signOut();
call.resolve();
}
@ActivityCallback
public void onSignInResult(PluginCall call, ActivityResult result) {
if (call == null) {
return;
}
Intent data = result.getData();
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {
GoogleSignInAccount account = task.getResult(ApiException.class);
JSObject response = new JSObject();
response.put("idToken", account.getIdToken());
call.resolve(response);
} catch (ApiException e) {
call.reject(e.getMessage());
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The intent is working fine, but you are getting a "developer error" on the So looks like you have something misconfigured in your app |
Beta Was this translation helpful? Give feedback.
-
E/Finsky (): [173] uks.a(849): Encountered exception whilst fetching from GMS, deferring to Finsky: com.google.android.gms.common.api.ApiException: 17: API: IntegrityApiDisplayListener.API is not available on this device. Connection failed with: ConnectionResult{statusCode=API_DISABLED, resolution=null, message=null} |
Beta Was this translation helpful? Give feedback.
The intent is working fine, but you are getting a "developer error" on the
ApiException
catchSo looks like you have something misconfigured in your app