Closed jeremy-hanna closed 3 years ago
If keeping backwards compatibility is important, this could be done:
crypto_args = [:sha256, client_secret, id <> issued_at_raw)]
if function_exported?(:crypto, :mac, 4) do
apply(:crypto, :mac, [:hmac] ++ crypto_args)
else
apply(:crypto, :hmac, crypto_args)
end
|> Base.encode64()
It ain't pretty, but it should work when :crypto.hmac
is yanked. I got this idea from https://www.kianmeng.org/2020/12/ensure-backward-compatibility-for-your.html
@jeremy-hanna could you make it work in older version with funciton_exported?
? Also could you add OTP 21 to CI config ? Since elixir 1.11 supports OTP 21 ref, and we need to test it :heart: for this change.
See https://github.com/elixir-lang/elixir/blob/v1.11.4/lib/elixir/lib/system.ex#L606 as an example. Let's define wrap the function def with the body as it does.
@JayAndCatchFire thanks for pointing it out! :heart:
SourceLevel has finished reviewing this Pull Request and has found:
Thanks @jeremy-hanna ! I made CI changes for recent Elixir (1.12) and OTP (24) releases and picked up changes of this PR into #56, which is just merged. Thanks again :tada:
@chulkilee any chance we can get a new release with this fix? Im getting errors using erlang 24 with ex_force
version 0.4.0
@Dacello I can release it this weekend. Please ping me again if I forget to do that!
@chulkilee pinging you since looks like we still dont have a new release! 😏
👋 Hi there, we are in the process of upgrading our systems and use of
:crypto.hmac/3
was scheduled for removal in OTP 24This PR is an update of the oauth.ex to the new api of
:crypto.mac/4
. I've tested our fork authenticating against our sandbox account and its been working fineThis will unfortunately put a lower bound on the version of OTP you can use as it was added in OTP 22 so it may be a breaking change, so let me know how you would like to proceed 🙂