-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update dependencies * bump version * fixup preferred_cli_env * bump version in README * set logger to info since bypass doesn't seem to work right * support request options * update client docs * remove param_key * clean up response module * support async response processing * fix code after rebase * various fixes * fix up bang functions to raise the correct error * convert response to an %Error{} when raising
- Loading branch information
Showing
13 changed files
with
224 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
language: elixir | ||
elixir: | ||
- 1.2.6 | ||
- 1.3.2 | ||
- 1.3.4 | ||
- 1.4.0 | ||
otp_release: | ||
- 18.3 | ||
- 19.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ end | |
|
||
defp deps do | ||
# Add the dependency | ||
[{:oauth2, "~> 0.8"}] | ||
[{:oauth2, "~> 0.9"}] | ||
end | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
use Mix.Config | ||
|
||
config :bypass, enable_debug_log: false | ||
config :logger, level: :info | ||
|
||
config :oauth2, | ||
client_id: "0bee1126b1a1381d9cab60bcd52349484451808a", # first commit sha of this library | ||
client_secret: "f715d64092fe81c396ac383e97f8a7eca40e7c89", #second commit sha | ||
redirect_uri: "http://example.com/auth/callback", | ||
serializers: %{"application/json" => Poison} | ||
serializers: %{"application/json" => Poison}, | ||
request_opts: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,50 @@ | ||
defmodule OAuth2.Serializer do | ||
@moduledoc false | ||
|
||
require Logger | ||
|
||
defmodule NullSerializer do | ||
@moduledoc false | ||
|
||
@doc false | ||
def decode!(content), do: content | ||
|
||
@doc false | ||
def encode!(content), do: content | ||
end | ||
|
||
def decode!(content, type), do: serializer(type).decode!(content) | ||
|
||
def encode!(content, type), do: serializer(type).encode!(content) | ||
|
||
defp serializer(type) do | ||
configured_serializers() | ||
|> Map.get(type, NullSerializer) | ||
serializer = Map.get(configured_serializers(), type, NullSerializer) | ||
warn_missing_serializer = Application.get_env(:oauth2, :warn_missing_serializer, true) | ||
|
||
if serializer == NullSerializer && warn_missing_serializer do | ||
Logger.warn """ | ||
A serializer was not configured for content-type '#{type}'. | ||
To remove this warning for this content-type, add the following to your `config.exs` file: | ||
config :oauth2, | ||
serializers: %{ | ||
"#{type}" => MySerializer | ||
} | ||
To remove this warning entirely, add the following to you `config.exs` file: | ||
config :oauth2, | ||
warn_missing_serializer: false | ||
""" | ||
end | ||
|
||
serializer | ||
end | ||
|
||
defp configured_serializers do | ||
Application.get_env(:oauth2, :serializers) || | ||
raise("Missing serializers configuration! Make sure oauth2 app is added to mix application list") | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.