如何在离子应用程序中实现谷歌驱动器

Fab*_*amo 0 cordova parse-platform google-drive-api ionic-framework

我需要连接我的离子应用谷歌驱动器,显示所有文件,也许上传,下载,删除,edit.So我试试这个 https://github.com/Raza-Dar/ionic-google-drive2

错误:无法加载资源:服务器响应状态为404(未找到)https://apis.google.com/ / scs/apps-static / /js/k=oz.gapi.en.RArmLpCIYB0.O/m ... 1/ed = 1/am = QQ/rs = AGLTcCOEiG2RgKkKDvOG7y5PZ-fMFMsJXQ/t = zcms/cb = gapi.loaded_01

未捕获的TypeError:无法调用未定义的方法'load'

找不到InAppBrowser插件

这个 http://blog.ionic.io/oauth-ionic-ngcordova/1 在控制台上没有错误......但是在认证之后返回到主页面

这个 http://excellencenodejsblog.com/cordova-ionic-google-oauth-login-for-your-mobile-app/ 用这个我得到用户的信息但不是驱动器中的文件

有什么建议吗?我需要一些工作示例入门代码谢谢

JcD*_*n86 5

您需要使用Google本地验证您的cordova应用程序才能使用API​​.首先,按照每个平台(iOS和Android)的官方Google指南(如果您还没有),为您的应用程序创建所需的凭据.然后尝试以下链接上的插件:

Cordova谷歌驱动器插件

我为个人移动项目创建了这个插件.此插件支持上载,下载和文件列表.

要检索Android应用程序创建/上传的文件列表,您可以在Java端尝试:

private void fileList() {
    Query query = new Query.Builder().addFilter(Filters.and(
            Filters.eq(SearchableField.MIME_TYPE, "application/octet-stream"),
            Filters.eq(SearchableField.TRASHED, false))).build();

    Drive.DriveApi.query(mGoogleApiClient, query)
            .setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
                @Override
                public void onResult(DriveApi.MetadataBufferResult result) {
                    if (!result.getStatus().isSuccess()) {
                        mCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR,"failed to retrieve file list"));
                        return;
                    }
                    MetadataBuffer flist = result.getMetadataBuffer();
                    Log.i(TAG,flist.get(0).getClass().getName());
                    JSONArray response = new JSONArray();
                    for (Metadata file: flist
                         ) {
                        try {
                            response.put(new JSONObject().put("name", file.getTitle()).put("created", file.getCreatedDate().toString()).put("id", file.getDriveId().toString()));
                        }catch (JSONException ex){ex.getMessage();}
                    }
                    JSONObject flistJSON = new JSONObject();
                    try{
                        flistJSON.put("flist", response);
                    } catch (JSONException ex){}
                    mCallbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK,flistJSON));
                    flist.release();
                    //Log.i(TAG,flist.toString());
                }
            });
}
Run Code Online (Sandbox Code Playgroud)