Skip to content

Using multiple scopes with Devise #62

@samstarling

Description

@samstarling

Hey @kmrshntr: do you have any pointers on using multiple scopes with Devise? I'd like the users for a Slack team to be able to "Sign in using Slack" (identity.basic scope) and then add my bot (bot scope). At the moment, I'm using a manual "Add to Slack" button (as per their documentation) which produces a link like this:

'https://slack.com/oauth/authorize?client_id=1234.5678&scope=bot

However, when it redirects back to my application, I get:

Started GET "/users/auth/slack/callback?code=snip&state=" for 127.0.0.1 at 2018-06-10 13:07:36 +0200
INFO -- omniauth: (slack) Callback phase initiated.
ERROR -- omniauth: (slack) Authentication failure! csrf_detected: OmniAuth::Strategies::OAuth2::CallbackError, csrf_detected | CSRF detected
Processing by Auth::OmniauthCallbacksController#failure as HTML
  Parameters: {"code"=>"snip", "state"=>""}

Two questions:

  1. Do you know why this is being detected as a CSRF? Ideally, an OAuth token would be returned by that call, that I could associate with the Team in my database.
  2. Can I have two config.omniauth :slack definitions in devise.rb, with different names? If so, how can I use those names when I'm generating links? Can I pass parameters to user_slack_omniauth_authorize_path?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions