ueberauth / ueberauth_slack

Slack OAuth2 Strategy for Überauth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

key :slack_team not found during callback

joemsak opened this issue · comments

Hello

I have set up my auth server according to your README and following the ueberauth example, however I am stuck with this error when trying to use the Slack button

https://api.slack.com/docs/slack-button

Request: GET /auth/slack/callback?code=32537399780.69572279236.f19e2f3c2f&state=
2016-08-15T18:45:44.932301+00:00 app[web.1]: ** (exit) an exception was raised:
2016-08-15T18:45:44.932304+00:00 app[web.1]:     ** (KeyError) key :slack_team not found in: %{EchochamberIo.Router => {[], %{}}, :phoenix_action => :callback, :phoenix_controller => EchochamberIo.AuthController, :phoenix_endpoint => EchochamberIo.Endpoint, :phoenix_flash => %{}, :phoenix_format => "html", :phoenix_layout => {EchochamberIo.LayoutView, :app}, :phoenix_pipelines => [:browser], :phoenix_route => #Function<10.117359548/1 in EchochamberIo.Router.match_route/4>, :phoenix_router => EchochamberIo.Router, :phoenix_view => EchochamberIo.AuthView, :plug_session => %{}, :plug_session_fetch => :done, :slack_auth => %{"ok" => true, "team" => "joemsak", "team_id" => "[FILTERED]", "url" => "https://joemsak.slack.com/", "user" => "joemsak", "user_id" => "[FILTERED]"}, :slack_token => %OAuth2.AccessToken{access_token: "[FILTERED]", client: %OAuth2.Client{authorize_url: "https://slack.com/oauth/authorize", client_id: "[FILTERED]", client_secret: "[FILTERED]", headers: [], params: %{"client_id" => "[FILTERED]", "client_secret" => "[FILTERED]", "code" => "[FILTERED]", "grant_type" => "authorization_code", "redirect_uri" => "https://echo-chmbr.herokuapp.com/auth/slack/callback"}, redirect_uri: "https://echo-chmbr.herokuapp.com/auth/slack/callback", site: "https://slack.com/api", strategy: Ueberauth.Strategy.Slack.OAuth, token_method: :post, token_url: "https://slack.com/api/oauth.access"}, expires_at: nil, other_params: %{"ok" => true, "scope" => "identify,users:read", "team_id" => "[FILTERED]", "team_name" => "joemsak", "user_id" => "[FILTERED]"}, refresh_token: nil, token_type: "Bearer"}, :slack_user => %{"color" => "9f69e7", "deleted" => false, "has_2fa" => false, "id" => "[FILTERED]", "is_admin" => true, "is_bot" => false, "is_owner" => true, "is_primary_owner" => true, "is_restricted" => false, "is_ultra_restricted" => false, "name" => "joemsak", "profile" => %{"avatar_hash" => "b082e9bf3676", "email" => "joe@joesak.com", "first_name" => "Joe", "image_1024" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_192.jpg", "image_192" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_192.jpg", "image_24" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_24.jpg", "image_32" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_32.jpg", "image_48" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_48.jpg", "image_512" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_192.jpg", "image_72" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_72.jpg", "image_original" => "https://avatars.slack-edge.com/2016-06-10/49902273206_b082e9bf36764cc67146_original.jpg", "last_name" => "Sak", "phone" => "517 944 5230", "real_name" => "Joe Sak", "real_name_normalized" => "Joe Sak", "skype" => "joemsak", "title" => "Software Craftsmanship Mentor"}, "real_name" => "Joe Sak", "status" => nil, "team_id" => "[FILTERED]", "tz" => "America/Indiana/Indianapolis", "tz_label" => "Eastern Daylight Time", "tz_offset" => -14400}, :ueberauth_request_options => %{callback_methods: ["GET"], callback_path: "/auth/slack/callback", callback_url: nil, options: [team: nil], request_path: "/auth/slack", strategy: Ueberauth.Strategy.Slack, strategy_name: :slack}}
2016-08-15T18:45:44.932305+00:00 app[web.1]:         (ueberauth_slack) lib/ueberauth/strategy/slack.ex:162: Ueberauth.Strategy.Slack.extra/1
2016-08-15T18:45:44.932305+00:00 app[web.1]:         (ueberauth_slack) lib/ueberauth/strategy/slack.ex:18: Ueberauth.Strategy.Slack.auth/1
2016-08-15T18:45:44.932306+00:00 app[web.1]:         (ueberauth) lib/ueberauth/strategy.ex:308: Ueberauth.Strategy.handle_callback_result/2
2016-08-15T18:45:44.932307+00:00 app[web.1]:         (ueberauth) lib/ueberauth/strategy.ex:300: Ueberauth.Strategy.run_callback/2
2016-08-15T18:45:44.932312+00:00 app[web.1]:         (echochamber_io) web/controllers/auth_controller.ex:1: EchochamberIo.AuthController.phoenix_controller_pipeline/2
2016-08-15T18:45:44.932313+00:00 app[web.1]:         (echochamber_io) lib/echochamber_io/endpoint.ex:1: EchochamberIo.Endpoint.instrument/4
2016-08-15T18:45:44.932313+00:00 app[web.1]:         (echochamber_io) lib/phoenix/router.ex:261: EchochamberIo.Router.dispatch/2
2016-08-15T18:45:44.932314+00:00 app[web.1]:         (echochamber_io) web/router.ex:1: EchochamberIo.Router.do_call/2
2016-08-15T18:45:44.852866+00:00 heroku[router]: at=info method=GET path="/auth/slack/callback?code=32537399780.69572279236.f19e2f3c2f&state=" host=echo-chmbr.herokuapp.com request_id=b03594f0-6219-45c5-b726-60b54f3fe35a fwd="50.232.114.250" dyno=web.1 connect=0ms service=260ms status=500 bytes=435

I get this error whether I add team:read to scopes or not

I had to define default_scope option in config for the type of auth I was trying to do.

@joemsak I'm getting this same error. I've tried changing the default_scope option, but I haven't found the right scope. What worked for you?

@joemsak I figured it out. Just in case anyone else runs across this issue, add "team:read" to your default_scope as shown here. I used default_scope: "users:read,team:read".

@jluckyiv Was just hitting this error and came across this, much thanks!