From f8841b7073f76ca8d163116575214c63c872fd94 Mon Sep 17 00:00:00 2001 From: Raj Rajhans Date: Sun, 17 Mar 2024 17:57:02 +0530 Subject: [PATCH] update to use System.os_time --- lib/goth.ex | 4 ++-- lib/goth/token.ex | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/goth.ex b/lib/goth.ex index 6429a4e..6e41f22 100644 --- a/lib/goth.ex +++ b/lib/goth.ex @@ -159,7 +159,7 @@ defmodule Goth do ] defp read_from_ets(name) do - now = :os.system_time(:second) + now = System.os_time(:second) case Registry.lookup(@registry, name) do [{_pid, %Token{expires: expires}}] when expires <= now -> nil @@ -267,7 +267,7 @@ defmodule Goth do defp store_and_schedule_refresh(state, token) do put(state.name, token) - time_in_seconds = max(token.expires - :os.system_time(:second) - state.refresh_before, 0) + time_in_seconds = max(token.expires - System.os_time(:second) - state.refresh_before, 0) Process.send_after(self(), :refresh, time_in_seconds * 1000) end diff --git a/lib/goth/token.ex b/lib/goth/token.ex index 17e6912..8b52bce 100644 --- a/lib/goth/token.ex +++ b/lib/goth/token.ex @@ -398,7 +398,7 @@ defmodule Goth.Token do defp build_token(%{"access_token" => _} = attrs) do %__MODULE__{ - expires: System.system_time(:second) + attrs["expires_in"], + expires: System.os_time(:second) + attrs["expires_in"], token: attrs["access_token"], type: attrs["token_type"], scope: attrs["scope"],