Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] 종가 갱신 스케줄링 메소드 실행전 액세스 토큰 발급 문제 #120

Closed
yonghwankim-dev opened this issue Jan 8, 2024 · 0 comments · Fixed by #127
Closed
Assignees
Labels
bug Something isn't working

Comments

@yonghwankim-dev
Copy link
Member

yonghwankim-dev commented Jan 8, 2024

상황

종가 갱신 스케줄링 메소드가 실행되었으나 토큰이 만료되어 갱신할 수 없습니다.
image

원인

kis 액세스 토큰이 만료되었는지 체크하는 aop(AccessTokenAspect)에서 종가 갱신 스케줄링 메소드를 추가하지 않았기 때문입니다. 액세스 토큰이 만료되었음에도 만료 체크를 하지 않고 실행되기 때문에 실패한 것입니다.

해결방법

종가 갱신 스케줄링 메소드 또한 aop에 추가하여 실행 전에 액세스 토큰이 만료되었다면 재발급하도록 합니다.

@Pointcut("execution(* codesquad.fineants.spring.api.kis.service.KisService.scheduleRefreshingAllLastDayClosingPrice())")
public void scheduleRefreshingAllLastDayClosingPrice() {
}
@Before(value = "scheduleRefreshingAllStockCurrentPrice() || scheduleRefreshingAllLastDayClosingPrice()")
public void checkAccessTokenExpiration() {
LocalDateTime now = LocalDateTime.now();
if (manager.isAccessTokenExpired(now)) {
redisService.getAccessTokenMap()
.ifPresentOrElse(manager::refreshAccessToken, () -> handleNewAccessToken(now));
}
}

@yonghwankim-dev yonghwankim-dev added the bug Something isn't working label Jan 8, 2024
@yonghwankim-dev yonghwankim-dev added this to the [BE] Sprint #13 milestone Jan 8, 2024
@yonghwankim-dev yonghwankim-dev self-assigned this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
1 participant