aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/VKService.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-09-08 22:38:11 +0300
committerGravatar Vitaly Takmazov2024-09-09 00:33:07 +0300
commitb94d06390216d645c61a27b77324a999ff1c11ef (patch)
treebed05dad9f60567626e4966a04453d8fb5ca92ff /src/main/java/com/juick/service/VKService.java
parentfccbba79ff9bb8795b94cae7685807cc3d7fcaf8 (diff)
Clean up social login
Diffstat (limited to 'src/main/java/com/juick/service/VKService.java')
-rw-r--r--src/main/java/com/juick/service/VKService.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/VKService.java b/src/main/java/com/juick/service/VKService.java
index b9b2483f..7f6b2516 100644
--- a/src/main/java/com/juick/service/VKService.java
+++ b/src/main/java/com/juick/service/VKService.java
@@ -30,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
+import org.springframework.web.util.UriComponentsBuilder;
import jakarta.inject.Inject;
@@ -40,7 +41,8 @@ public class VKService {
private String VK_APPID;
@Value("${vk_secret:secret}")
private String VK_SECRET;
- private static final String VK_REDIRECT = "https://juick.com/_vklogin";
+ @Value("${ap_base_uri:http://localhost:8080/}")
+ private String baseUri;
@Inject
private ObjectMapper jsonMapper;
@Inject
@@ -49,10 +51,12 @@ public class VKService {
@PostConstruct
public void init() {
+ UriComponentsBuilder redirectBuilder = UriComponentsBuilder.fromUriString(baseUri);
+ String redirectUri = redirectBuilder.replacePath("/_vklogin").build().toUriString();
ServiceBuilder vkBuilder = new ServiceBuilder(VK_APPID);
setVkAuthService(vkBuilder.apiSecret(VK_SECRET)
.defaultScope("friends,wall,offline,groups")
- .callback(VK_REDIRECT)
+ .callback(redirectUri)
.build(VkontakteApi.instance()));
}