Можно ли изменить информацию агента пользователя для вызовов API в Google IAM, когда мы ее создадим?Мой код выглядит так:
public static Iam initIam() throws IOException, GeneralSecurityException {
InputStream resourceAsStream = GoogleIAM.class.getClassLoader().getResourceAsStream("creds.txt");
GoogleCredential credential = GoogleCredential.fromStream(resourceAsStream);
httpTransport = GoogleNetHttpTransport.newTrustedTransport();
if (credential.createScopedRequired()) {
List<String> scopes = new ArrayList<>();
// Enable full Cloud Platform scope.
scopes.add(IamScopes.CLOUD_PLATFORM);
credential = credential.createScoped(scopes);
}
// Create IAM API object associated with the authenticated transport.
return new Iam.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName("test").build();
}
Я видел, что для Google Storage возможно использование HeaderProvider следующим образом:
Map<String, String> m = ImmutableMap.<String, String>builder().put("user-agent", "my custom useragent").build();
HeaderProvider headerProvider = FixedHeaderProvider.create(m);
, но я не смог выяснить, как использовать HeaderProvider в GoogleЯ.
Есть идеи?