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 26, 2024
1 parent 99ddaef commit b0c1791
Show file tree
Hide file tree
Showing 34 changed files with 2,821 additions and 12 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 @@ -24,24 +24,27 @@ public final class GoogleServiceSupplierUtil {
private GoogleServiceSupplierUtil() {}

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);
return googleCredentials;
}
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 b0c1791

Please sign in to comment.