Class: GitFit::Sync::GarminBaseDI
- Inherits:
-
GarminBase
- Object
- Base
- GarminBase
- GitFit::Sync::GarminBaseDI
- Defined in:
- lib/git_fit/sync/garmin_base_di.rb
Direct Known Subclasses
Constant Summary collapse
- DI_CLIENT_IDS =
%w[ GARMIN_CONNECT_MOBILE_ANDROID_DI_2025Q2 GARMIN_CONNECT_MOBILE_ANDROID_DI_2024Q4 GARMIN_CONNECT_MOBILE_ANDROID_DI ].freeze
Constants inherited from GarminBase
GitFit::Sync::GarminBase::CLIENT_ID, GitFit::Sync::GarminBase::OAUTH_CONSUMER_URL, GitFit::Sync::GarminBase::SSO_HEADERS
Instance Attribute Summary
Attributes inherited from GarminBase
Attributes inherited from Base
#auth_method, #progress_reported
Instance Method Summary collapse
Methods inherited from GarminBase
#initialize, #pending_ids, #process_one
Methods inherited from Base
adapters, #build_progress_info, #call, camelcase_to_snakecase, config_key, #initialize, #pending_ids, #process_one, register_adapter, register_config, register_test_adapter, test_adapters
Constructor Details
This class inherits a constructor from GitFit::Sync::GarminBase
Instance Method Details
#authenticate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/git_fit/sync/garmin_base_di.rb', line 15 def authenticate @oauth_consumer = fetch_oauth_consumer if load_tokens if access_token_valid? @auth_method = 'token' return true end begin if refresh_token @auth_method = 'refreshed' return true end rescue AuthError remove_stale_tokens end end if load_auth_seed if access_token_valid? @auth_method = 'seed' return true end begin if refresh_token @auth_method = 'refreshed' return true end rescue AuthError @access_token = nil end end puts 'Garmin: no valid DI token found' puts ' First time: ./scripts/garmin_auth_local.sh' puts ' Refresh: ./scripts/garmin_auth_local.sh --sync' false end |
#before_call ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/git_fit/sync/garmin_base_di.rb', line 54 def before_call if @config['auth_seed'].to_s.empty? && !File.exist?(token_path) puts 'Garmin: auth_seed not configured and no cached token' puts ' Run: ./scripts/garmin_auth_local.sh' return false end @start_time = Time.now true end |
#reauth_hint ⇒ Object
64 65 66 |
# File 'lib/git_fit/sync/garmin_base_di.rb', line 64 def reauth_hint 'Re-auth: ./scripts/garmin_auth_local.sh --sync' end |