Sha256: becd529582a2b4f2506ab84b66d680980b543149619c11065b502616178829ab

Contents?: true

Size: 596 Bytes

Versions: 11

Compression:

Stored size: 596 Bytes

Contents

module Wework
  module Token
    class Store

      attr_accessor :app

      def initialize(app)
        @app = app
      end

      def access_token
        refresh_token if expired?
      end

      def expired?
        raise NotImplementedError, "Subclasses must implement a token_expired? method"
      end

      def refresh_token
        app.request.get 'gettoken', params: {corpid: app.corp_id, corpsecret: app.app_secret}
      end

      private

      def key
        @key ||= Digest::MD5.hexdigest("#{ACCESS_TOKEN_PREFIX}_#{app.app_id}_#{app.app_secret}")
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wework-0.2.5 lib/wework/token/store.rb
wework-0.2.4 lib/wework/token/store.rb
wework-0.2.3 lib/wework/token/store.rb
wework-0.2.2 lib/wework/token/store.rb
wework-0.2.0 lib/wework/token/store.rb
wework-0.1.9 lib/wework/token/store.rb
wework-0.1.8 lib/wework/token/store.rb
wework-0.1.7 lib/wework/token/store.rb
wework-0.1.6 lib/wework/token/store.rb
wework-0.1.4 lib/wework/token/store.rb
wework-0.1.3 lib/wework/token/store.rb