Use an access token because it avoids the rate limit.

This commit is contained in:
James Harton 2018-04-10 18:16:17 +12:00
parent bc966b7b9c
commit 2945694453
3 changed files with 13 additions and 2 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@
/db /db
/deps /deps
/*.ez /*.ez
.envrc
# Generated on crash by the VM # Generated on crash by the VM
erl_crash.dump erl_crash.dump

View file

@ -22,6 +22,8 @@ config :logger, :console,
config :faces, Faces.Repo, migration_timestamps: [type: :utc_datetime] config :faces, Faces.Repo, migration_timestamps: [type: :utc_datetime]
config :faces, Faces.Gallery.GithubUserData, access_token: System.get_env("GITHUB_ACCESS_TOKEN")
# Import environment specific config. This must remain at the bottom # Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above. # of this file so it overrides the configuration defined above.
import_config "#{Mix.env()}.exs" import_config "#{Mix.env()}.exs"

View file

@ -36,7 +36,15 @@ defmodule Faces.Gallery.GithubUserData do
defp get_user_from_github(username) do defp get_user_from_github(username) do
username username
|> Users.find(Client.new()) |> Users.find(github_client())
end
defp github_client, do: Client.new(%{access_token: github_access_token()})
defp github_access_token do
:faces
|> Application.get_env(__MODULE__, [])
|> Keyword.get(:access_token)
end end
defp just_the_facts(user_data) do defp just_the_facts(user_data) do