class OmniAuth::Strategies::Mastodon
Constants
- DEFAULT_SCOPE
Public Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/mastodon.rb, line 40 def callback_phase set_options_from_identifier super end
callback_url()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 49 def callback_url full_host + script_name + callback_path end
raw_info()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 45 def raw_info @raw_info ||= access_token.get('api/v1/accounts/verify_credentials').parsed end
request_phase()
click to toggle source
Before we can redirect the user to authorize access, we must know where the user is from If the identifier param is not already present, a form will be shown for entering it
# File lib/omniauth/strategies/mastodon.rb, line 36 def request_phase identifier ? start_oauth : get_identifier end
Private Instance Methods
get_identifier()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 61 def get_identifier form = OmniAuth::Form.new(title: 'Mastodon Login') form.text_field 'Your full Mastodon identifier (username@domain)', 'identifier' form.button 'Login' form.to_response end
identifier()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 73 def identifier i = options.identifier || request.params['identifier'] || (env['omniauth.params'].is_a?(Hash) ? env['omniauth.params']['identifier'] : nil) || session[:identifier] i = i.downcase.strip unless i.nil? i = nil if i == '' session[:identifier] = i unless i.nil? i end
set_options_from_identifier()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 81 def set_options_from_identifier username, domain = identifier.split('@') client_id, client_secret = options.credentials.call(domain, callback_url) options.identifier = identifier options.client_options[:site] = "https://#{domain}" options.client_id = client_id options.client_secret = client_secret end
start_oauth()
click to toggle source
# File lib/omniauth/strategies/mastodon.rb, line 68 def start_oauth set_options_from_identifier redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(authorize_params)) end