|
@@ -1,11 +1,11 @@
|
|
|
package com.wechi.adweb.bridge.google.gtm.service;
|
|
|
|
|
|
-import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
|
|
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
|
|
-import com.google.api.client.http.HttpTransport;
|
|
|
import com.google.api.client.json.gson.GsonFactory;
|
|
|
import com.google.api.services.tagmanager.TagManager;
|
|
|
import com.google.api.services.tagmanager.TagManagerScopes;
|
|
|
+import com.google.auth.http.HttpCredentialsAdapter;
|
|
|
+import com.google.auth.oauth2.GoogleCredentials;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
@@ -32,16 +32,18 @@ public class GTMService {
|
|
|
@PostConstruct
|
|
|
private void init() throws GeneralSecurityException, IOException {
|
|
|
// Service account authorization;
|
|
|
- HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
|
|
|
- GoogleCredential credential =
|
|
|
- GoogleCredential.fromStream(
|
|
|
+ GoogleCredentials credentials =
|
|
|
+ GoogleCredentials.fromStream(
|
|
|
this.getClass()
|
|
|
.getClassLoader()
|
|
|
.getResourceAsStream(serviceAccountKey))
|
|
|
.createScoped(TagManagerScopes.all());
|
|
|
|
|
|
this.tagManager =
|
|
|
- new TagManager.Builder(httpTransport, GsonFactory.getDefaultInstance(), credential)
|
|
|
+ new TagManager.Builder(
|
|
|
+ GoogleNetHttpTransport.newTrustedTransport(),
|
|
|
+ GsonFactory.getDefaultInstance(),
|
|
|
+ new HttpCredentialsAdapter(credentials))
|
|
|
.build();
|
|
|
}
|
|
|
}
|