如何通过服务帐户身份验证从iOS应用上传到Google云端硬盘存储空间?

时间:2014-05-12 04:00:57

标签: ios google-drive-api

我没有找到任何iPhone应用程序的解决方案。请帮助我的IOS应用程序。

我通过以下代码完成了android应用程序:

java.io.File file = getTempPkc12File();

    ArrayList<String> scopes = new ArrayList<String>();
    scopes.add(DriveScopes.DRIVE);
    scopes.add(DriveScopes.DRIVE_FILE);
    scopes.add(DriveScopes.DRIVE_SCRIPTS);

    HttpTransport httpTransport = new NetHttpTransport();

    JacksonFactory jsonFactory = new JacksonFactory();

    GoogleCredential credential = new GoogleCredential.Builder()
            .setTransport(httpTransport).setJsonFactory(jsonFactory)
            .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
            .setServiceAccountScopes(scopes)
            .setServiceAccountPrivateKeyFromP12File(file).build();

    service = new Drive.Builder(httpTransport, jsonFactory, null)
            .setHttpRequestInitializer(credential).build();