-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commit 7d5ae39 breaks AuthCode Strategy for GitHub #64
Comments
Hi @smetana, the referenced commit was to make the AuthCode.get_token!(client, client_secret: client.client_secret, code: "...") That should do the trick. |
It does. Maybe it should be noticed in README because current strategy example does not work. |
👍 |
I can't get this work. ## strategy callback
def get_token(client, params, headers) do
params = params |> Keyword.merge([client_secret: client.client_secret])
# [code: "***", client_secret: "***"]
client
|> put_header("accept", "application/json")
|> OAuth2.Strategy.AuthCode.get_token(params, headers)
end |
Ok so i get the token from github but I failed when I request the api: def callback(conn, %{"code" => code}) do
client = GitHub.get_token!(code: code)
user = get_user!(client) # failed here
conn
|> put_session(:current_user, user)
|> redirect(to: "/")
end
defp get_user!(client) do
case OAuth2.Client.get(client, "/user") do
{:ok, %{status_code: 401, body: body}} ->
IO.inspect body # <-- get 401 here
raise("Unauthorized token")
{:ok, %{status_code: status_code, body: user}} when status_code in [200..399] ->
user
{:error, %{reason: reason}} ->
Logger.error("Error: #{inspect reason}")
end
end |
I gave up and implemented it by myself. |
@yang-wei care to share a link to your implementation? |
The issue is in commit 7d5ae39
Removing client_secret from params makes GitHub to return "incorrect_client_credentials"
As per https://developer.github.com/v3/oauth/#web-application-flow client_secret is required to exchange authorization_code for access_token
The text was updated successfully, but these errors were encountered: