Class: OmniAuth::Etencent::AccessToken

Inherits:
OAuth2::AccessToken
  • Object
show all
Defined in:
lib/omniauth-etencent/access_token.rb

Class Method Summary collapse

Class Method Details

.from_hash(client, hash) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/omniauth-etencent/access_token.rb', line 5

def from_hash(client, hash)
  return unless hash && hash['code'] == 0 && hash.dig('data', 'access_token')

  data = hash['data'].merge('expires_in' => hash.dig('data', 'access_token_expires_in'))
  data['refresh_token_expires_at'] ||= Time.now.to_i + data['refresh_token_expires_in'].to_i if data['refresh_token_expires_in'].to_i > 0
  super(client, data)
end