Class: OmniAuth::Strategies::Lexoffice
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Lexoffice
- Defined in:
- lib/omniauth/strategies/lexoffice.rb
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #basic_auth_header(client_id, client_secret) ⇒ Object
- #callback_url ⇒ Object
- #redirect(uri) ⇒ Object
- #request_phase ⇒ Object
-
#setup_phase ⇒ Object
These are called after authentication has succeeded.
- #token_params ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
31 32 33 34 35 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 31 def # params = super params = {client_id: .client_id, response_type:'code'} params.merge!(super) end |
#basic_auth_header(client_id, client_secret) ⇒ Object
69 70 71 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 69 def basic_auth_header(client_id, client_secret) 'Basic ' + Base64.encode64(client_id + ':' + client_secret).delete("\n") end |
#callback_url ⇒ Object
46 47 48 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 46 def callback_url full_host + script_name + callback_path end |
#redirect(uri) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 50 def redirect(uri) r = Rack::Response.new if [:iframe] r.write("<script type='text/javascript' charset='utf-8'> window.setTimeout(function() { window.top.location.href = '#{uri}'; // this window will not open }, 100); </script>") else r.write("Redirecting to #{uri}...") r.redirect(uri) end r.finish end |
#request_phase ⇒ Object
41 42 43 44 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 41 def request_phase #authorize call redirect client.auth_code.({:redirect_uri => callback_url}.merge()) end |
#setup_phase ⇒ Object
These are called after authentication has succeeded. If possible, you should try to set the UID without making additional calls (if the user id is returned with the token or as a URI parameter). This may not be possible with all providers.
26 27 28 29 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 26 def setup_phase super end |
#token_params ⇒ Object
37 38 39 |
# File 'lib/omniauth/strategies/lexoffice.rb', line 37 def token_params .token_params.merge!(:headers => {'Authorization' => basic_auth_header(.client_id,.client_secret), 'Accept' => 'application/json' }) end |