Skip to content

Commit

Permalink
update hackney to remedy https bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ecly committed Oct 2, 2019
1 parent 43de6a3 commit 238d997
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
30 changes: 21 additions & 9 deletions apps/fortnite_api/lib/fortnite_api/access_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule FortniteApi.AccessServer do
alias Poison.Parser
alias HTTPoison

@csrf_url "https://www.epicgames.com/id/api/csrf"
@oauth_token_url "https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token"
@oauth_exchange_url "https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/exchange"

Expand Down Expand Up @@ -53,6 +54,17 @@ defmodule FortniteApi.AccessServer do
"""
def get_headers_bearer(token), do: [{"Authorization", "bearer #{token}"}]

def new_login() do
email = Application.fetch_env!(:fortnite_api, :fortnite_api_email)
password = Application.fetch_env!(:fortnite_api, :fortnite_api_password)
launch_token = Application.fetch_env!(:fortnite_api, :fortnite_api_key_launcher)
headers = get_headers_basic(launch_token)

res = HTTPoison.get(@csrf_url)


end

defp fetch_refreshed_tokens(refresh_token) do
Logger.debug(fn -> "Refreshing access token for Fortnite API" end)
key_client = Application.fetch_env!(:fortnite_api, :fortnite_api_key_client)
Expand All @@ -67,6 +79,15 @@ defmodule FortniteApi.AccessServer do
|> handle_json()
end

# Fetches an oauth exchange token based on initial oauth token
defp fetch_oauth_exchange(access_token) do
headers = get_headers_bearer(access_token)

@oauth_exchange_url
|> HTTPoison.get(headers)
|> handle_json()
end

# Fetches an initial oauth token based on login creds
defp fetch_oauth() do
email = Application.fetch_env!(:fortnite_api, :fortnite_api_email)
Expand All @@ -88,15 +109,6 @@ defmodule FortniteApi.AccessServer do
|> handle_json()
end

# Fetches an oauth exchange token based on initial oauth token
defp fetch_oauth_exchange(access_token) do
headers = get_headers_bearer(access_token)

@oauth_exchange_url
|> HTTPoison.get(headers)
|> handle_json()
end

# This results in the final valid access_token
defp fetch_oauth(exchange_code) do
client_token = Application.fetch_env!(:fortnite_api, :fortnite_api_key_client)
Expand Down
1 change: 1 addition & 0 deletions apps/fortnite_api/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ defmodule FortniteApi.Mixfile do
[
{:poison, "~> 3.1"},
{:httpoison, "~> 0.13"},
{:hackney, ">= 1.15.2", override: true},
{:ok, "~> 1.9"},
{:conform, "~> 2.2"},
{:mock, "~> 0.3.0", only: :test},
Expand Down
1 change: 1 addition & 0 deletions apps/riot_api/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ defmodule RiotApi.Mixfile do
{:poison, "~> 3.1"},
{:ok, "~> 1.9"},
{:httpoison, "~> 0.13"},
{:hackney, ">= 1.15.2", override: true},
{:mock, "~> 0.3.0", only: :test}
]
end
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"edeliver": {:hex, :edeliver, "1.7.0", "aafb99e55bbb88a725390978304f92a5002871fbd56e2d23970ca7f164338e41", [:mix], [{:distillery, "~> 2.1.0", [hex: :distillery, repo: "hexpm", optional: true]}], "hexpm"},
"excoveralls": {:hex, :excoveralls, "0.11.1", "dd677fbdd49114fdbdbf445540ec735808250d56b011077798316505064edb2c", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"gettext": {:hex, :gettext, "0.17.0", "abe21542c831887a2b16f4c94556db9c421ab301aee417b7c4fbde7fbdbe01ec", [:mix], [], "hexpm"},
"hackney": {:hex, :hackney, "1.15.1", "9f8f471c844b8ce395f7b6d8398139e26ddca9ebc171a8b91342ee15a19963f4", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"},
"httpoison": {:hex, :httpoison, "0.13.0", "bfaf44d9f133a6599886720f3937a7699466d23bb0cd7a88b6ba011f53c6f562", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
"idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
Expand All @@ -32,7 +32,7 @@
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"},
"pre_commit": {:hex, :pre_commit, "0.2.4", "e26feaa149d55d3a6f14ca1340bd8738942d98405de389c0b3c7d48e71e62d66", [:mix], [], "hexpm"},
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"},
"telemetry": {:hex, :telemetry, "0.4.0", "8339bee3fa8b91cb84d14c2935f8ecf399ccd87301ad6da6b71c09553834b2ab", [:rebar3], [], "hexpm"},
"timex": {:hex, :timex, "3.6.1", "efdf56d0e67a6b956cc57774353b0329c8ab7726766a11547e529357ffdc1d56", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm"},
"tzdata": {:hex, :tzdata, "1.0.1", "f6027a331af7d837471248e62733c6ebee86a72e57c613aa071ebb1f750fc71a", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm"},
Expand Down

0 comments on commit 238d997

Please sign in to comment.