Adding default scopes
This commit is contained in:
parent
63309f0857
commit
6324b606da
|
@ -20,7 +20,7 @@ Example:
|
|||
|
||||
```ruby
|
||||
Rails.application.config.middleware.use OmniAuth::Builder do
|
||||
provider :mastodon, credentials: lambda { |domain, callback_url|
|
||||
provider :mastodon, scope: 'read write follow', credentials: lambda { |domain, callback_url|
|
||||
Rails.logger.info "Requested credentials for #{domain} with callback URL #{callback_url}"
|
||||
|
||||
existing = MastodonClient.find_by(domain: domain)
|
||||
|
|
|
@ -12,7 +12,7 @@ module OmniAuth
|
|||
end
|
||||
|
||||
def patch
|
||||
0
|
||||
1
|
||||
end
|
||||
|
||||
def pre
|
||||
|
|
|
@ -3,10 +3,13 @@ require 'omniauth-oauth2'
|
|||
module OmniAuth
|
||||
module Strategies
|
||||
class Mastodon < OmniAuth::Strategies::OAuth2
|
||||
DEFAULT_SCOPE = 'read'.freeze
|
||||
|
||||
option :name, 'mastodon'
|
||||
|
||||
option :credentials
|
||||
option :identifier
|
||||
option :authorize_options, [:scope]
|
||||
|
||||
option :client_options, {
|
||||
authorize_url: '/oauth/authorize',
|
||||
|
@ -47,6 +50,12 @@ module OmniAuth
|
|||
full_host + script_name + callback_path
|
||||
end
|
||||
|
||||
def authorize_params
|
||||
super.tap do |params|
|
||||
params[:scope] ||= DEFAULT_SCOPE
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_identifier
|
||||
|
|
Loading…
Reference in New Issue