add configurable redirect uri

This commit is contained in:
Lee 2024-06-28 03:05:36 +01:00
parent 2dc04394fe
commit bf6bd8080d
3 changed files with 8 additions and 4 deletions

@ -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

@ -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")

@ -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"