Skip to content

Commit

Permalink
Server relative URL for access token endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuhot committed Dec 30, 2020
1 parent 898b7dd commit a0367be
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions examples/phoenix_app/lib/phoenix_app_web/api_spec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ defmodule PhoenixAppWeb.ApiSpec do
flows: %OAuthFlows{
authorizationCode: %OAuthFlow{
authorizationUrl: "https://github.com/login/oauth/authorize",
# tokenUrl: "https://github.com/login/oauth/access_token",
tokenUrl: "http://localhost:4000/oauth/access_token",
tokenUrl: "/oauth/access_token",
scopes: %{"user:email" => "Read your email address."}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
defmodule PhoenixAppWeb.OauthController do
use PhoenixAppWeb, :controller

def access_token(conn, _params) do
{:ok, body, conn} = Plug.Conn.read_body(conn, length: 1_000_000)
body = URI.decode_query(body)
provider_params = body
def access_token(conn = %Plug.Conn{}, _params) do
provider_params = conn.body_params

provider_response = HTTPoison.post!(
"https://github.com/login/oauth/access_token",
Expand Down
2 changes: 1 addition & 1 deletion examples/phoenix_app/lib/phoenix_app_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ defmodule PhoenixAppWeb.Endpoint do
plug Plug.RequestId
plug Plug.Logger
plug Plug.Static, at: "/", from: {:phoenix_app, "priv/static"}
plug Plug.Parsers, parsers: [:json], pass: ["*/*"], json_decoder: Jason
plug Plug.Parsers, parsers: [:urlencoded, :json], pass: ["*/*"], json_decoder: Jason
plug PhoenixAppWeb.Router
end

0 comments on commit a0367be

Please sign in to comment.