Wow!
Yea @NobbZ I really missed saying that Authorization is “Bearer abcde”.
Thanks for bearing with my newbieness but I am accumulating the lessons thru realizations and you response definitely added to it.
Will be correcting my question above for the rest of the newbies to refer to.
Thanks so much @NobbZ!
Well, literally that… I have seen implementations with the type beeing sent with a capital B as first letter and with a lower case b. Unless you controll all API consumers, you should make it a low effort to talk to the API.
def get_bearer_token(header_value) do
with [method, data] <- String.split("Bearer abcdef", " ", parts: 2),
"bearer" <- String.downcase(method) do
{:ok, data}
else
{:error, :no_bearer}
end
end
Other ways with a delegating function with a pipe and some helpers are thinkable. But I prefer some monadic with here.