question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android ClientId do not working, but Web ClientId do working

See original GitHub issue

There are many comment about API Exception: 10

I think most important thing is SHA fingerprint. (Android app and google android client must have the same fingerprint.) So I copy SHA from ~/.android/debug.keystore

keytool -keystore ~/.android/debug.keystore -list -v

Also I can get SHA from android studio → gradle → tasks → android → signingReport image

copy SHA1 and past to android client. image

But it is not working ! why ?? (error : something went wrong)

I use capacitor3 and vue2 without firebase

below is my config about capacitor and MainActivity

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.example',
  appName: 'name',
  webDir: 'dist',
  bundledWebRuntime: false,
  server: {
    hostname: 'localhost:8080',
    url: 'http://192.168.0.21:8080/',
    cleartext: true,
  },
  plugins: {
    GoogleAuth: {
      androidClientId:
        'android-client-id',
      scopes: ['profile', 'email'],
      forceCodeForRefreshToken: false,
    },
  },
};

export default config;
package com.example;

import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;


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

Using Web client

If you used the Web ClientId, google signin is working.

So android type is not working but web application type is working

If you change only androidClientId to WebClient in the same setting as above, it will work.

GoogleAuth: {
      androidClientId:
        'web-client-id',
      scopes: ['profile', 'email'],
      forceCodeForRefreshToken: false,
    },

How Can I use AndroidClientId ? and why WebClient working good ?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
sawaca96commented, Dec 13, 2021

Finally, I figured out how to use android

For androidClientId in capacitor config, use the client id of the web application Also, To authenticate through the app’s sha-1 fingerprint, we also need to create an Android client. After creation, you need to put the app’s sha-1 in the Android client.(At this time, if you are using google console app signing, enter sha-1 in google console)

I don’t know how the web application client communicates with the android client either. However, as a result of testing, when using the above method, it worked well in both development and deployment environments.

Summary

  • Create both web application client and android client. (google cloud platform)
  • For capacitor, androidClientID : <web application client Id> should be used. (capacitor)
  • Enter the correct sha-1 in the android client. (google cloud platform)
1reaction
Lzolcsicommented, May 12, 2022

@sawaca96 Using web client ID instead of android solved the issue for me, thanks! Maybe this is because the capacitor app in the end is a simple webview and therefore should be using the web client id? Anyway, the point is that it’s working now, thanks for the suggestion!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google sign in doesn't work with client id - Stack Overflow
This account has an OAuth client registered for Android (SHA1 and package name are correct). The problem is when I try to add...
Read more >
Setup | Authentication - Google Developers
If your project doesn't have a Web application-type client ID, click Create credentials > OAuth client ID to create one.
Read more >
Authentication - Expo Documentation
There are 4 different types of client IDs you can provide: expoClientId : Proxy client ID for use in the Expo Go on...
Read more >
App Settings | Spotify for Developers
The app provides, among others, the Client ID and Client Secret needed to ... have a URL scheme handled by your application for...
Read more >
Resolve unresolved default_web_client_id | by Chetan Gupta
It's a very common error to run into while adding a google sign-in button to your android app using firebase auth, this is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found