-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathheaders.jl
34 lines (28 loc) · 1.03 KB
/
headers.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function json_headers!(headers::AbstractDict)
headers["Accept"] = "application/json"
headers["Content-Type"] = "application/json"
return headers
end
function authentication_headers!(headers::AbstractDict, client::Client)::Nothing
auth = get_auth(client)
authentication_headers!(headers, auth)
return nothing
end
function authentication_headers!(headers::AbstractDict, auth::AnonymousAuth)::Nothing
return nothing
end
function authentication_headers!(headers::AbstractDict, oauth2::OAuth2)::Nothing
headers["Authorization"] = "Bearer $(get_token(oauth2))"
return nothing
end
function authentication_headers!(headers::AbstractDict, jwt_auth::JWTAuth)::Nothing
headers["Authorization"] = "Bearer $(get_token(jwt_auth))"
return nothing
end
function authentication_headers!(
headers::AbstractDict,
password_auth::UsernamePassAuth,
)::Nothing
headers["Authorization"] = "Basic $(Base64.base64encode(string(get_username(password_auth), ':', get_password(password_auth))))"
return nothing
end