Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions distributions/demo-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ dependencies {

// TODO: depend on these based on list in flag values.

compile project(':extensions:auth:portability-auth-amazon')
compile project(':extensions:data-transfer:portability-data-transfer-amazon')
compile project(':extensions:auth:portability-auth-apple')
compile project(':extensions:auth:portability-auth-daybook')
compile project(':extensions:auth:portability-auth-deezer')
Expand Down
12 changes: 12 additions & 0 deletions extensions/auth/portability-auth-amazon/build.gradle
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)
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());
}
}
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(
Comment thread
vipulkala95 marked this conversation as resolved.
"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"))
Comment thread
vipulkala95 marked this conversation as resolved.
.put(VIDEOS, ImmutableSet.of("photos::videos:read", "photos::albums:read"))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.datatransferproject.auth.amazon.AmazonAuthServiceExtension
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");
}
}
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"
Comment thread
vipulkala95 marked this conversation as resolved.
}
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;
}
}
Loading
Loading