Skip to content

Commit

Permalink
feat(gemini): impl connector
Browse files Browse the repository at this point in the history
  • Loading branch information
DenovVasil committed Nov 13, 2024
1 parent 91b06f0 commit 7a9bcff
Show file tree
Hide file tree
Showing 21 changed files with 1,936 additions and 20 deletions.
4 changes: 4 additions & 0 deletions bundle/default-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
<groupId>io.camunda.connector</groupId>
<artifactId>connector-aws-comprehend</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-google-gemini</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 5 additions & 0 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@
<artifactId>connector-aws-comprehend</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-google-gemini</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,31 @@ public final class GoogleServiceSupplierUtil {

private GoogleServiceSupplierUtil() {}

public static final String CLOUD_SCOPE = "https://www.googleapis.com/auth/cloud-platform";

public static HttpCredentialsAdapter getHttpHttpCredentialsAdapter(final Authentication auth) {
Credentials creds = null;
Credentials creds = getCredentials(auth);
if (auth.authType() == AuthenticationType.BEARER) {
AccessToken accessToken = new AccessToken(auth.bearerToken(), null);
creds = new GoogleCredentials(accessToken).createScoped(DriveScopes.DRIVE);
}

if (auth.authType() == AuthenticationType.REFRESH) {
creds =
UserCredentials.newBuilder()
.setClientId(auth.oauthClientId())
.setClientSecret(auth.oauthClientSecret())
.setRefreshToken(auth.oauthRefreshToken())
.build();
creds = ((GoogleCredentials) creds).createScoped(DriveScopes.DRIVE);
}

return new HttpCredentialsAdapter(creds);
}

public static Credentials getCredentials(Authentication auth) {
if (auth.authType() == AuthenticationType.BEARER) {
AccessToken accessToken = new AccessToken(auth.bearerToken(), null);
GoogleCredentials googleCredentials = new GoogleCredentials(accessToken);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
GoogleCredentials.GoogleCredentials
should be avoided because it has been deprecated.
return googleCredentials;
// .createScoped(CLOUD_SCOPE);
}
return UserCredentials.newBuilder()
.setClientId(auth.oauthClientId())
.setClientSecret(auth.oauthClientSecret())
.setRefreshToken(auth.oauthRefreshToken())
.build();
}

public static NetHttpTransport getNetHttpTransport() {
try {
return GoogleNetHttpTransport.newTrustedTransport();
Expand Down
Loading

0 comments on commit 7a9bcff

Please sign in to comment.