From bf6bd8080d4fb3213f858ea34bc5537cc3cb410a Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 28 Jun 2024 03:05:36 +0100 Subject: [PATCH] add configurable redirect uri --- Dockerfile | 4 ++++ .../java/cc/fascinated/bat/service/SpotifyService.java | 7 +++---- src/main/resources/application.yml | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3fcbe1..6ecd2e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,5 +19,9 @@ WORKDIR /home/container # Copy the built jar file from the builder stage COPY --from=builder /home/container/target/Bat.jar . +# Export the port +ENV PORT=8080 +EXPOSE $PORT + # Run the jar file CMD java -jar Bat.jar -Djava.awt.headless=true \ No newline at end of file diff --git a/src/main/java/cc/fascinated/bat/service/SpotifyService.java b/src/main/java/cc/fascinated/bat/service/SpotifyService.java index 0978662..1d81239 100644 --- a/src/main/java/cc/fascinated/bat/service/SpotifyService.java +++ b/src/main/java/cc/fascinated/bat/service/SpotifyService.java @@ -24,8 +24,6 @@ import java.util.concurrent.TimeUnit; @Service @Getter public class SpotifyService { - private static final String REDIRECT_URI = "http://localhost:8080/spotify/callback"; - /** * The access token map. */ @@ -58,7 +56,8 @@ public class SpotifyService { */ private final String authorizationUrl; - public SpotifyService(@Value("${spotify.client-id}") String clientId, @Value("${spotify.client-secret}") String clientSecret, @NonNull UserService userService) { + public SpotifyService(@Value("${spotify.client-id}") String clientId, @Value("${spotify.client-secret}") String clientSecret, + @Value("${spotify.redirect-uri}") String redirectUri, @NonNull UserService userService) { this.clientId = clientId; this.clientSecret = clientSecret; this.userService = userService; @@ -66,7 +65,7 @@ public class SpotifyService { this.spotifyApi = new SpotifyApi.Builder() .setClientId(clientId) .setClientSecret(clientSecret) - .setRedirectUri(URI.create(REDIRECT_URI)) + .setRedirectUri(URI.create(redirectUri)) .build(); this.authorizationUrl = spotifyApi.authorizationCodeUri() .response_type("code") diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index dbae21a..0333029 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,6 +4,7 @@ discord: # Spotify Configuration spotify: + redirect-uri: "http://localhost:8080/spotify/callback" client-id: "spotify-client-id" client-secret: "spotify-client-secret"