Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Created October 16, 2017 13:30
Show Gist options
  • Save salrashid123/e401dfacd0d1c881bb09f697a3827397 to your computer and use it in GitHub Desktop.
Save salrashid123/e401dfacd0d1c881bb09f697a3827397 to your computer and use it in GitHub Desktop.
Proxy-GoogleCloud
HttpTransportFactory hf = new HttpTransportFactory(){
@Override
public HttpTransport create() {
return mHttpTransport;
}
};
com.google.auth.oauth2.GoogleCredentials credential = com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(hf);
if (credential.createScopedRequired())
credential = credential.createScoped(Arrays.asList("https://www.googleapis.com/auth/devstorage.read_write"));
TransportOptions options = HttpTransportOptions.newBuilder().setHttpTransportFactory(hf).build();
com.google.cloud.storage.Storage storage = com.google.cloud.storage.StorageOptions.newBuilder()
.setCredentials(credential)
.setProjectId("your_project")
.setTransportOptions(options)
.build().getService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment