Search code examples
androidgoogle-identity-toolkit

Google Identity Toolkit: Android client ID


I have been playing with the GIT for a while now, and I am a bit confused with the two client IDs in AndroidManifest

android:scheme="INSERT_REVERSED_SERVER_CLIENT_ID"
android:name="identitytoolkit.server_client_id"
android:value="INSERT_YOUR_SERVER_CLIENT_ID"

It looks like changing the value of [android:scheme] does not have any effect on GIT. And for some reason for [identitytoolkit.server_client_id] I can only use web client ID. If I plug in Android client ID from the dev console, GIT fails for Google accounts.

Could somebody please explain how this is supposed to work?


Solution

  • Your Android Manifest should look roughly like this:

    ...
    <application>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.SEARCH" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
    
                <!-- The scheme value is the reversed web Application Client ID -->
                <data
                    android:host="gitkit"
                    android:scheme="com.googleusercontent.apps.[SOME NUMBERS]-[SOME NUMBERS AND LETTERS]" />
            </intent-filter>
        </activity>
    
        <meta-data
            android:name="identitytoolkit.server_client_id"
            android:value="[SOME NUMBERS]-[SOME NUMBERS AND LETTERS].apps.googleusercontent.com" />
    
    </application>
    ...
    

    Both [SOME NUMBERS] replacement values should match exactly, as should both [SOME NUMBERS AND LETTERS] replacement values. This Client ID is generated by Google when you create a new OAuth 2.0 Client ID of type "Web application." I know, it seems weird that you have to create a Web application client ID for your android app, but you do.

    You can see this tutorial for further help! Hope that helps!