Android Google 驱动器访问

Android Google Drive access

我正在尝试从模拟器上的 android 应用程序访问我的 Goodle Drive 帐户。 我一直关注:https://developers.google.com/drive/android/auth 关于 授权 Android 应用程序 但我仍然无法授权自己。 因此,OAuth 在开发人员控制台上创建,Public API 访问 也被创造出来。 但我仍然得到:

08-04 13:09:22.154    1683-1711/com.google.process.gapps W/GLSActivity﹕ gms.StatusHelper Status from wire: INVALID_KEY status: null
08-04 13:09:22.154    1683-1711/com.google.process.gapps I/GLSUser﹕ GLS error: INVALID_KEY my_mail@gmail.com oauth2:https://www.googleapis.com/auth/drive.file
08-04 13:09:22.160    1664-2522/com.google.android.gms E/ClientConnectionOperation﹕ Handling authorization failure
    com.google.android.gms.drive.auth.c: Authorization failed: See https://developers.google.com/drive/android/auth for details on authorizing an application.

此外,我同意:

  <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission android:name="android.permission.USE_CREDENTIALS"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />

正如

   <activity
            android:name="com.google.android.gms.drive.sample.demo.HomeActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data
                android:name="com.google.android.apps.drive.APP_ID"
                android:value="329914295769-9e34odtlolkc6sqavaj5uqrduik1ouml.apps.googleusercontent.com" />

        </activity>

但是我尝试时仍然无法验证自己:

        if (mGoogleApiClient == null) {
            mGoogleApiClient = new GoogleApiClient.Builder(this)
                    .addApi(Drive.API)
                    .addScope(Drive.SCOPE_FILE)
//                    .addScope(Drive.SCOPE_APPFOLDER) // required for App Folder sample
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .setAccountName("erakovic.boban@gmail.com")
                    .build();
        }
        mGoogleApiClient.connect();

其中 mGoogleApiClient 是 GoogleApiClient 实例。 我整个早上都在谷歌上搜索,尽我所能,但仍然一无所获。 我只是想知道为什么 证书指纹 (SHA1),因为应用程序在模拟器上 运行,所以实际上,我们在开始生成已签名 APK 的过程之前不会对其进行签名。

我做错了什么,我没有得到?

谢谢

为了调试,如果您在 DeveloperConsole 中创建 API 密钥,请不要使用密钥库中的证书指纹 (SHA1) 来创建签名的应用程序。 对于未签名的应用程序(从 Eclipse 直接安装到设备、模拟器...)必须使用来自 debug.keystore.

的指纹 (SHA1)

默认存储位置 debug.keystore 文件在 ~/.android/ on OS X and Linux, in C:\Documents and Settings\.android\ 在 Windows XP 上,在 C:\Users\.android\ 在 Windows Vista 和 Windows 7.

您可以使用 keytool 命令从 debug.keystore 获取 SHA1 keytool -list -keystore debug.keystore

keytool 默认位置是 c:\Program Files\Java\jdk1.7.0_21\bin\