From 1153bdfd7c4f4a6dc0bb93d8a8264522570cf742 Mon Sep 17 00:00:00 2001 From: Oldes Date: Thu, 20 Jul 2023 21:26:09 +0200 Subject: [PATCH] FIX: update expiration time of a newly refreshed token --- spotify.reb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spotify.reb b/spotify.reb index 3bee5fc..ef60545 100644 --- a/spotify.reb +++ b/spotify.reb @@ -267,14 +267,16 @@ refresh: function[ ]) ] data: attempt [load-json result/3] - either result/1 >= 400 [ + if result/1 >= 400 [ sys/log/error 'SPOTIFY "Failed to refresh access token!" if data/error_description [ sys/log/error 'SPOTIFY data/error_description ] - none - ][ - attempt [data/expires_in: now + (to time! data/expires_in)] - ctx/token: data + return none ] + try/with [ + data/expires_in: now + (to time! data/expires_in) + ctx/token: data + store-config ctx + ] :print ] request: func [