Class: ClickfunnelsAuth::AccessToken
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ClickfunnelsAuth::AccessToken
- Defined in:
- app/models/clickfunnels_auth/access_token.rb
Instance Method Summary collapse
Instance Method Details
#expired? ⇒ Boolean
30 31 32 |
# File 'app/models/clickfunnels_auth/access_token.rb', line 30 def expired? oauth_token.expired? end |
#refresh! ⇒ Object
7 8 9 10 |
# File 'app/models/clickfunnels_auth/access_token.rb', line 7 def refresh! new_token = oauth_token.refresh! self.save_token_data(new_token) end |
#save_token_data(token) ⇒ Object
12 13 14 15 16 17 18 |
# File 'app/models/clickfunnels_auth/access_token.rb', line 12 def save_token_data(token) self.update_attributes({ token: token.token, refresh_token: token.refresh_token, expires_at: Time.at(token.expires_at) }) end |
#validate_token! ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/models/clickfunnels_auth/access_token.rb', line 20 def validate_token! user_data = oauth_token.get(ENV['AUTH_PROVIDER_ME_URL']).parsed user_id = user_data['id'] puts "we got a user_id = #{user_id}" rescue OAuth2::Error => e puts "caught an error #{e}" puts e.as_json self.destroy end |