Skip to content

Commit

Permalink
Merge pull request #77 from ohmree/master
Browse files Browse the repository at this point in the history
Added the ability to set request headers in OAuth2.fetch_user/4
  • Loading branch information
danschultzer committed Jan 5, 2021
2 parents dbaaef9 + 87d086c commit 25819cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.1.22 (TBA)

* `Assent.Strategy.OAuth2.fetch_user/4` now accepts headers in arguments

## v0.1.21 (2020-12-29)

* `Assent.Strategy.OAuth` now handles missing params in callback phase
Expand Down
6 changes: 3 additions & 3 deletions lib/assent/strategies/oauth2.ex
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ defmodule Assent.Strategy.OAuth2 do
Uses `request/6` to fetch the user data.
"""
@spec fetch_user(Config.t(), map(), map() | Keyword.t()) :: {:ok, map()} | {:error, term()}
def fetch_user(config, token, params \\ []) do
@spec fetch_user(Config.t(), map(), map() | Keyword.t(), [{binary(), binary()}]) :: {:ok, map()} | {:error, term()}
def fetch_user(config, token, params \\ [], headers \\ []) do
with {:ok, user_url} <- Config.fetch(config, :user_url) do
config
|> request(token, :get, user_url, params)
|> request(token, :get, user_url, params, headers)
|> process_user_response()
end
end
Expand Down

0 comments on commit 25819cc

Please sign in to comment.