Google Identity Toolkit:Android客户端ID

时间:2015-12-01 06:31:11

标签: android google-identity-toolkit

我一直在玩GIT一段时间了,我对AndroidManifest中的两个客户端ID感到困惑

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

看起来改变[android:scheme]的值对GIT没有任何影响。由于某种原因[identitytoolkit.server_client_id]我只能使用Web客户端ID。如果我从开发控制台插入Android客户端ID,GIT就无法使用Google帐户。

有人可以解释一下这应该如何运作吗?

1 个答案:

答案 0 :(得分:1)

你的Android Manifest应该大致如下:

...
<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>
...

两个[SOME NUMBERS]替换值应该完全匹配,[SOME NUMBERS AND LETTERS]替换值也应该匹配。当您创建类型为&#34; Web应用程序的新OAuth 2.0客户端ID时,Google会生成此客户端ID。我知道,你必须为你的Android应用程序创建一个Web应用程序客户端ID似乎很奇怪,但你确实如此。

您可以看到this tutorial以获得进一步的帮助!希望有所帮助!

相关问题