Sha256: 9574646a07e230b710f013e23940fae950667adf8f1a5bd008b0523d346ebb74

Contents?: true

Size: 886 Bytes

Versions: 17

Compression:

Stored size: 886 Bytes

Contents

module Roqua
  module CoreApi
    module Sessions
      class OAuthSession < AuthSession
        attr_reader :access_token

        def initialize(access_token:, **additional_arguments)
          @access_token = access_token
          super additional_arguments
        end

        def logout_url(return_to:)
          "#{core_site}/session/destroy?token=#{access_token}&return_to=#{CGI.escape return_to}"
        end

        # ping the server to check if session is still valid.
        # Will throw NoSession as usual if not.
        def ping
          get "/ping"
        end

        private

        def access_denied(response)
          if response['no_session']
            fail NoSession
          else
            fail Unauthorized
          end
        end

        def headers
          {"Authorization" => "Bearer #{access_token}"}
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
roqua-core-api-0.2.1 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.2.0 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.1.1 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.1.0 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.39 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.38 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.37 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.36 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.35 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.32 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.31 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.30 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.29 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.28 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.27 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.26 lib/roqua/core_api/sessions/oauth_session.rb
roqua-core-api-0.0.25 lib/roqua/core_api/sessions/oauth_session.rb