Module: OAuth2::Provider::Models::AccessToken::ClassMethods

Defined in:
lib/oauth2/provider/models/access_token.rb

Instance Method Summary collapse

Instance Method Details

#refresh_with(refresh_token) ⇒ Object


44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/oauth2/provider/models/access_token.rb', line 44

def refresh_with(refresh_token)
  if refresh_token && token = find_by_refresh_token(refresh_token)
    if token.refreshable?
      new(:authorization => token.authorization).tap do |result|
        if result.authorization.expires_at && result.authorization.expires_at < result.expires_at
          result.expires_at = result.authorization.expires_at
        end
        result.save!
      end
    end
  end
end