-
Notifications
You must be signed in to change notification settings - Fork 498
feat: Add Amazon Photos importer extension #1500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vipulkala95
merged 1 commit into
dtinit:master
from
vipulkala95:feat/amazon-photos-integration
Jul 1, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| plugins { | ||
| id 'maven' | ||
| id 'signing' | ||
| } | ||
|
|
||
| dependencies { | ||
| compile project(':portability-spi-api') | ||
| compile project(':portability-spi-cloud') | ||
| compile project(':libraries:auth') | ||
| } | ||
|
|
||
| configurePublication(project) |
9 changes: 9 additions & 0 deletions
9
...-amazon/src/main/java/org/datatransferproject/auth/amazon/AmazonAuthServiceExtension.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.datatransferproject.auth.amazon; | ||
|
|
||
| import org.datatransferproject.auth.OAuth2ServiceExtension; | ||
|
|
||
| public class AmazonAuthServiceExtension extends OAuth2ServiceExtension { | ||
| public AmazonAuthServiceExtension() { | ||
| super(new AmazonOAuthConfig()); | ||
| } | ||
| } |
55 changes: 55 additions & 0 deletions
55
...lity-auth-amazon/src/main/java/org/datatransferproject/auth/amazon/AmazonOAuthConfig.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package org.datatransferproject.auth.amazon; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import com.google.common.collect.ImmutableSet; | ||
| import org.datatransferproject.auth.OAuth2Config; | ||
| import org.datatransferproject.types.common.models.DataVertical; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import static org.datatransferproject.types.common.models.DataVertical.PHOTOS; | ||
| import static org.datatransferproject.types.common.models.DataVertical.VIDEOS; | ||
|
|
||
| /** | ||
| * OAuth2 configuration for Amazon Photos (Login with Amazon). | ||
| */ | ||
| public class AmazonOAuthConfig implements OAuth2Config { | ||
|
|
||
| @Override | ||
| public String getServiceName() { | ||
| return "Amazon"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getAuthUrl() { | ||
| return "https://www.amazon.com/ap/oa"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getTokenUrl() { | ||
| return "https://api.amazon.com/auth/o2/token"; | ||
| } | ||
|
|
||
| @Override | ||
| public Map<DataVertical, Set<String>> getImportScopes() { | ||
| return ImmutableMap.<DataVertical, Set<String>>builder() | ||
| .put(PHOTOS, ImmutableSet.of( | ||
| "photos::images:create", | ||
| "photos::albums:create", | ||
| "photos::albums:update")) | ||
| .put(VIDEOS, ImmutableSet.of( | ||
| "photos::videos:create", | ||
| "photos::albums:create", | ||
| "photos::albums:update")) | ||
| .build(); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<DataVertical, Set<String>> getExportScopes() { | ||
| return ImmutableMap.<DataVertical, Set<String>>builder() | ||
| .put(PHOTOS, ImmutableSet.of("photos::images:read", "photos::albums:read")) | ||
|
vipulkala95 marked this conversation as resolved.
|
||
| .put(VIDEOS, ImmutableSet.of("photos::videos:read", "photos::albums:read")) | ||
| .build(); | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
...ces/META-INF/services/org.datatransferproject.spi.api.auth.extension.AuthServiceExtension
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.datatransferproject.auth.amazon.AmazonAuthServiceExtension |
63 changes: 63 additions & 0 deletions
63
...-auth-amazon/src/test/java/org/datatransferproject/auth/amazon/AmazonOAuthConfigTest.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package org.datatransferproject.auth.amazon; | ||
|
|
||
| import static com.google.common.truth.Truth.assertThat; | ||
| import static org.datatransferproject.types.common.models.DataVertical.PHOTOS; | ||
| import static org.datatransferproject.types.common.models.DataVertical.VIDEOS; | ||
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class AmazonOAuthConfigTest { | ||
|
|
||
| private AmazonOAuthConfig config; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| config = new AmazonOAuthConfig(); | ||
| } | ||
|
|
||
| @Test | ||
| void serviceName() { | ||
| assertThat(config.getServiceName()).isEqualTo("Amazon"); | ||
| } | ||
|
|
||
| @Test | ||
| void authUrlIsLwaEndpoint() { | ||
| assertThat(config.getAuthUrl()).isEqualTo("https://www.amazon.com/ap/oa"); | ||
| } | ||
|
|
||
| @Test | ||
| void tokenUrlIsLwaEndpoint() { | ||
| assertThat(config.getTokenUrl()).isEqualTo("https://api.amazon.com/auth/o2/token"); | ||
| } | ||
|
|
||
| @Test | ||
| void importScopesForPhotos() { | ||
| assertThat(config.getImportScopes().get(PHOTOS)) | ||
| .containsExactly( | ||
| "photos::images:create", | ||
| "photos::albums:create", | ||
| "photos::albums:update"); | ||
| } | ||
|
|
||
| @Test | ||
| void importScopesForVideos() { | ||
| assertThat(config.getImportScopes().get(VIDEOS)) | ||
| .containsExactly( | ||
| "photos::videos:create", | ||
| "photos::albums:create", | ||
| "photos::albums:update"); | ||
| } | ||
|
|
||
| @Test | ||
| void exportScopesForPhotos() { | ||
| assertThat(config.getExportScopes().get(PHOTOS)) | ||
| .containsExactly("photos::images:read", "photos::albums:read"); | ||
| } | ||
|
|
||
| @Test | ||
| void exportScopesForVideos() { | ||
| assertThat(config.getExportScopes().get(VIDEOS)) | ||
| .containsExactly("photos::videos:read", "photos::albums:read"); | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
extensions/data-transfer/portability-data-transfer-amazon/build.gradle
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /* | ||
| * Copyright 2026 The Data Transfer Project Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| id 'java' | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation project(':portability-spi-cloud') | ||
| implementation project(':portability-spi-transfer') | ||
| implementation project(':portability-transfer') | ||
| implementation project(':portability-spi-api') | ||
| implementation project(':portability-types-common') | ||
| implementation project(':portability-types-transfer') | ||
| implementation project(':portability-api-launcher') | ||
|
|
||
| implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}" | ||
| implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" | ||
| implementation "com.google.guava:guava:${guavaVersion}" | ||
| implementation "com.squareup.okhttp3:okhttp:4.9.0" | ||
|
|
||
| testImplementation "com.squareup.okhttp3:mockwebserver:4.9.0" | ||
|
vipulkala95 marked this conversation as resolved.
|
||
| } | ||
79 changes: 79 additions & 0 deletions
79
...amazon/src/main/java/org/datatransferproject/transfer/amazon/AmazonTransferExtension.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Copyright 2026 The Data Transfer Project Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.datatransferproject.transfer.amazon; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import org.datatransferproject.api.launcher.ExtensionContext; | ||
| import org.datatransferproject.api.launcher.Monitor; | ||
| import org.datatransferproject.spi.cloud.storage.AppCredentialStore; | ||
| import org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore; | ||
| import org.datatransferproject.spi.transfer.extension.TransferExtension; | ||
| import org.datatransferproject.spi.transfer.provider.Exporter; | ||
| import org.datatransferproject.spi.transfer.provider.Importer; | ||
| import org.datatransferproject.transfer.amazon.photos.AmazonPhotosImporter; | ||
| import org.datatransferproject.types.common.models.DataVertical; | ||
| import org.datatransferproject.types.transfer.auth.AppCredentials; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class AmazonTransferExtension implements TransferExtension { | ||
|
|
||
| private static final String SERVICE_ID = "Amazon"; | ||
|
|
||
| private AmazonPhotosImporter importer; | ||
| private volatile boolean initialized = false; | ||
|
|
||
| @Override | ||
| public String getServiceId() { | ||
| return SERVICE_ID; | ||
| } | ||
|
|
||
| @Override | ||
| public Exporter<?, ?> getExporter(DataVertical transferDataType) { | ||
| // TODO: Implement exporter | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public Importer<?, ?> getImporter(DataVertical transferDataType) { | ||
| Preconditions.checkArgument(initialized, "Extension not initialized"); | ||
| Preconditions.checkArgument(transferDataType == DataVertical.PHOTOS); | ||
| return importer; | ||
| } | ||
|
|
||
| @Override | ||
| public synchronized void initialize(ExtensionContext context) { | ||
| if (initialized) return; | ||
|
|
||
| Monitor monitor = context.getMonitor(); | ||
|
|
||
| AppCredentials appCredentials; | ||
| try { | ||
| appCredentials = context.getService(AppCredentialStore.class) | ||
| .getAppCredentials("AMAZON_KEY", "AMAZON_SECRET"); | ||
| } catch (IOException e) { | ||
| monitor.severe(() -> "Unable to retrieve Amazon AppCredentials.", e); | ||
| return; | ||
| } | ||
|
|
||
| importer = new AmazonPhotosImporter( | ||
| monitor, appCredentials.getKey(), appCredentials.getSecret(), | ||
| context.getService(TemporaryPerJobDataStore.class)); | ||
|
|
||
| initialized = true; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.