Class: OmniAuth::Strategies::ScanSnap
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::ScanSnap
- Defined in:
- lib/omniauth/strategies/scansnap.rb
Constant Summary collapse
- MAX_STATE_LENGTH =
36
Instance Method Summary collapse
Instance Method Details
#authorization ⇒ Object
37 38 39 40 41 |
# File 'lib/omniauth/strategies/scansnap.rb', line 37 def raw = "#{[:client_id]}:#{[:client_secret]}" encoded = Base64.strict_encode64(raw) "Basic #{encoded}" end |
#setup_phase ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/omniauth/strategies/scansnap.rb', line 10 def setup_phase [:client_options].merge!( site: site, authorize_url: '/oauth2/authorize', token_url: '/api/oauth2/token' ) [:token_params][:headers] = { 'Authorization' => } [:state] = SecureRandom.hex(MAX_STATE_LENGTH / 2) end |
#site ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth/strategies/scansnap.rb', line 26 def site country = .delete(:country) language = .delete(:language) locale = language ? "#{language}_#{country}" : country region_api_uri = .delete(:region_api_uri) || "https://api.cloud.scansnap.com/api/region/" response = Faraday.get("#{region_api_uri}#{locale}") body = JSON.parse(response.body) body['auth_url'] end |