|
|
@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.client.RestClientException;
|
|
|
|
import org.springframework.web.client.RestClientException;
|
|
|
@ -38,9 +39,17 @@ public class ShopifyAuthService {
|
|
|
|
@Qualifier("shopifyRestTemplate")
|
|
|
|
@Qualifier("shopifyRestTemplate")
|
|
|
|
private RestTemplate restTemplate;
|
|
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
public ShopifyPermissionURL shopifyPermission(String shopifyStoreHost, String hmac, String timestamp) {
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ShopifyPermissionURL shopifyPermission(String shopifyStoreHost) {
|
|
|
|
String redirectUri = PlatformEnvironment.getEnv().concatUrl("/auth.html");
|
|
|
|
String redirectUri = PlatformEnvironment.getEnv().concatUrl("/auth.html");
|
|
|
|
String permissionUrl = String.format(PERMISSION_URL, shopifyStoreHost, clientId, scope, redirectUri, String.valueOf(new Date().getTime()).substring(0,10));
|
|
|
|
|
|
|
|
|
|
|
|
String state = String.valueOf(new Date().getTime()).substring(0,10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stringRedisTemplate.boundValueOps("shopifyAuthState:"+shopifyStoreHost).set(state);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String permissionUrl = String.format(PERMISSION_URL, shopifyStoreHost, clientId, scope, redirectUri, state);
|
|
|
|
return ShopifyPermissionURL.builder().url(permissionUrl).build();
|
|
|
|
return ShopifyPermissionURL.builder().url(permissionUrl).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|