ueberauth / ueberauth_github

GitHub OAuth2 Strategy for Überauth
MIT License
102 stars 53 forks source link

Unable to handle :error response #57

Closed chasers closed 4 years ago

chasers commented 4 years ago

Hi! Any suggestions on how to handle this? There have been a few other cases of :error responses from Github and I'm not sure how to handle.

This seems to be the issue: https://github.com/ueberauth/ueberauth_github/blob/9eeeb20ca5df6576a9f75c2d9c7b18fe74635268/lib/ueberauth/strategy/github.ex#L247

PID<0.10868.1759> running LogflareWeb.Endpoint (connection #PID<0.8105.1766>, stream id 75) terminated Server: logflare.app:80 (http) Request: GET /auth/github/callback?code=aac5e62e511dd94b2827 (exit) an exception was raised: (CaseClauseError) no case clause matching: {:error, %OAuth2.Response{body: %{"documentation_url" => "https://developer.github.com/v3", "message" => "Bad credentials"}, headers: [{"server", "GitHub.com"}, {"date", "Mon, 18 May 2020 09:16:52 GMT"}, {"content-type", "application/json; charset=utf-8"}, {"content-length", "83"}, {"status", "401 Unauthorized"}, {"x-github-media-type", "github.v3"}, {"x-ratelimit-limit", "60"}, {"x-ratelimit-remaining", "59"}, {"x-ratelimit-reset", "1589797012"}, {"access-control-expose-headers", "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset"}, {"access-control-allow-origin", "*"}, {"strict-transport-security", "max-age=31536000; includeSubdomains; preload"}, {"x-frame-options", "deny"}, {"x-content-type-options", "nosniff"}, {"x-xss-protection", "1; mode=block"}, {"referrer-policy", "origin-when-cross-origin, strict-origin-when-cross-origin"}, {"content-security-policy", "default-src 'none'"}, {"vary", "Accept-Encoding, Accept, X-Requested-With"}, {"x-github-request-id", "0411:1906:321A12:9A4723:5EC25284"}], status_code: 401}} (ueberauth_github 0.8.0) lib/ueberauth/strategy/github.ex:236: Ueberauth.Strategy.Github.fetch_user/2 (ueberauth 0.6.3) lib/ueberauth/strategy.ex:307: Ueberauth.Strategy.run_callback/2 (logflare 0.8.2) lib/logflare_web/controllers/auth/oauth_controller.ex:1: LogflareWeb.Auth.OauthController.phoenix_controller_pipeline/2 (phoenix 1.4.17) lib/phoenix/router.ex:288: Phoenix.Router.call/2 (logflare 0.8.2) lib/logflare_web/endpoint.ex:1: LogflareWeb.Endpoint.plug_builder_call/2 (logflare 0.8.2) lib/logflare_web/endpoint.ex:1: LogflareWeb.Endpoint.call/2 (phoenix 1.4.17) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4 (cowboy 2.7.0) /logflare/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2

Hanspagh commented 4 years ago

Closed by #58