0
アプリケーションはプロキシサーバー経由でhttps://www.googleapi.com
にアクセスする運用サーバーで実行されています。だからhttps://www.googleapi.com
の代わりにURLを設定する方法http://www.googleapi.com:443
。GoogleドライブAPIのURLの変更
現在使用されているもののサンプルコードは、上記のコードでURLを変更する方法
File dataStoreDir = new File(resourceDir, credentials);
JsonFactory jacksonFactory = JacksonFactory.getDefaultInstance();
//List<String> scopes = Arrays.asList(DriveScopes.DRIVE);
List<String> scopes = Arrays.asList("http://www.googleapis.com/auth/drive:443");
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
FileDataStoreFactory dataStoreFactory = new FileDataStoreFactory(dataStoreDir);
String clientSecret = config.getClientSecret();
InputStream in = new FileInputStream(new File(resourceDir, clientSecret));
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(jacksonFactory, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jacksonFactory, clientSecrets, scopes)
.setDataStoreFactory(dataStoreFactory)
.setAccessType("offline")
.setAuthorizationServerEncodedUrl("http://www.googleapis.com/auth/drive:443")
.build();
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
logger.info("Credentials saved to " + dataStoreDir.getAbsolutePath());
drive = new Drive.Builder(
httpTransport, jacksonFactory, credential)
.setApplicationName(applicationName)
.build();
のですか?私はdrive
インスタンスの作成を変更すると は
drive = new Drive.Builder(
httpTransport, jacksonFactory, credential)
.setApplicationName(applicationName).setRootUrl("http://www.googleapis.com:443/")
.build();
は、その後、それは誤り
ERROR [2016-05-03 18:39:10,847] com.test.intranet.sao.GoogleDocSAO: Connection reset
! java.net.SocketException: Connection reset
! at java.net.SocketInputStream.read(SocketInputStream.java:209) ~[na:1.8.0_65]
! at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_65]
! at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_65]
! at java.io.BufferedInputStream.read1(BufferedInputStream.java:286) ~[na:1.8.0_65]
! at java.io.BufferedInputStream.read(BufferedInputStream.java:345) ~[na:1.8.0_65]
! at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704) ~[na:1.8.0_65]
! at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647) ~[na:1.8.0_65]
! at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:675) ~[na:1.8.0_65]
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536) ~[na:1.8.0_65]
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) ~[na:1.8.0_65]
! at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) ~[na:1.8.0_65]
! at com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:37) ~[google-http-client-1.20.0.jar:1.20.0]
! at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:94) ~[google-http-client-1.20.0.jar:1.20.0]
! at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:972) ~[google-http-client-1.20.0.jar:1.20.0]
! at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) ~[google-api-client-1.20.0.jar:1.20.0]
! at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) ~[google-api-client-1.20.0.jar:1.20.0]
! at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469) ~[google-api-client-1.20.0.jar:1.20.0]
を与える