Created
October 16, 2017 13:30
-
-
Save salrashid123/e401dfacd0d1c881bb09f697a3827397 to your computer and use it in GitHub Desktop.
Proxy-GoogleCloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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