GoogleNetHttpTransport.newTrustedTransport() returning Null

巧了我就是萌 提交于 2019-12-22 07:29:10

问题


I'm trying to load Google credential from json file. So before that, I knew, we have to get the default Google transport. Ref from. But it always gives null. Is anybody faced this issue?

This is my snippet:

try {
        JSON_FACTORY =  JacksonFactory.getDefaultInstance();
        HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();

    } catch (Throwable t) {
        Utilities.writeToLogFile(Constants.LOG_ERROR_LEVEL, ".. EXCEPTION" + t.toString());
    }

This always ends with catch part. says as below

... EXCEPTIONjava.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore JKS implementation not found

回答1:


Finally, I've found an answer on google issue tracker.

Replace

HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();

with

HTTP_TRANSPORT = new com.google.api.client.http.javanet.NetHttpTransport()

But don't know, how it's working.




回答2:


You can also use. From Tasks API sample by Google

AndroidHttp.newCompatibleTransport();


来源:https://stackoverflow.com/questions/39248453/googlenethttptransport-newtrustedtransport-returning-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!