omniauth-slack
omniauth-slack copied to clipboard
Send access_token_class as client option
In order to adapt to the new code on Oauth2 gem we send the access_token_class as client param instead of sending it as param to get_token method
Fixes https://github.com/ginjo/omniauth-slack/issues/22
Thanks @ozmar-salesloft for the fix, it works well on my side. While waiting for the pull request to be merged, is there a way to use this fix without forking ? Like monkey patching ?
Thanks @ozmar-salesloft, works for me as well 🏆
Hi @ginjo!! :wave:
Would it be possible to get this reviewed/merged? Let me know if I can help out!
If there a way to apply this fix while we are waiting for the next release?
We tried specify client_options: when in our initializer when setting up the slack provider, but that didn't work.
If there a way to apply this fix while we are waiting for the next release?
We tried specify
client_options:when in our initializer when setting up the slack provider, but that didn't work.
You can fork the repo with the fix and pull that in. Or, monkey patch with something like:
module OmniAuth
module Slack
module OAuth2
class Client < ::OAuth2::Client
# Wraps OAuth2::Client#get_token to pass in the omniauth-slack AccessToken class.
def get_token(params, access_token_opts = {})
debug{"params #{params}, access_token_opts #{access_token_opts}"}
rslt = super(params, access_token_opts)
debug{"Client #{self} built AccessToken #{rslt}"}
rslt
end
end
end
end
module Strategies
class Slack < OmniAuth::Strategies::OAuth2
option :client_options, {
access_token_class: OmniAuth::Slack::OAuth2::AccessToken,
auth_scheme: :basic_auth,
authorize_url: '/oauth/v2/authorize',
history: Array.new,
raise_errors: false, # MUST be false to allow Slack's get-token response from v2 API.
site: 'https://slack.com',
token_url: '/api/oauth.v2.access',
}
end
end
end