Sha256: e6a4a13f81113bbc2fa8f066f5531dbb5d07af79b381621db28c89faa77c716d

Contents?: true

Size: 1019 Bytes

Versions: 34

Compression:

Stored size: 1019 Bytes

Contents

module Kontena::Cli::Master::Token
  module Common

    def token_data_to_hash(data)
      output = {
        id: data["id"],
        token_type:  data["token_type"] || data["grant_type"],
        scopes: data["scopes"],
        user_id: data["user"]["id"],
        user_email: data["user"]["email"],
        user_name: data["user"]["name"],
        server_name: data["server"]["name"],
        description: data['description']
      }
      if data["token_type"] == "bearer"
        output[:access_token_last_four] = data["access_token_last_four"]
        output[:refresh_token_last_four] = data["refresh_token_last_four"]
        output[:token_type] =  data["token_type"]
        output[:access_token] = data["access_token"] if data["access_token"]
        output[:refresh_token] = data["refresh_token"] if data["refresh_token"]
        output[:expires_in] = data["expires_in"]
      else
        output[:code] = data["code"]
        output[:token_type] =  data["grant_type"]
      end
      output
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/master/token/common.rb
krates-1.7.10 lib/kontena/cli/master/token/common.rb
krates-1.7.9 lib/kontena/cli/master/token/common.rb
krates-1.7.8 lib/kontena/cli/master/token/common.rb
krates-1.7.7 lib/kontena/cli/master/token/common.rb
krates-1.7.6 lib/kontena/cli/master/token/common.rb
krates-1.7.5 lib/kontena/cli/master/token/common.rb
krates-1.7.4 lib/kontena/cli/master/token/common.rb
krates-1.7.3 lib/kontena/cli/master/token/common.rb
krates-1.7.2 lib/kontena/cli/master/token/common.rb
krates-1.7.1 lib/kontena/cli/master/token/common.rb
krates-1.7.0 lib/kontena/cli/master/token/common.rb
krates-1.6.9 lib/kontena/cli/master/token/common.rb
krates-1.6.8 lib/kontena/cli/master/token/common.rb
krates-1.6.7 lib/kontena/cli/master/token/common.rb
krates-1.6.6 lib/kontena/cli/master/token/common.rb
krates-1.6.5 lib/kontena/cli/master/token/common.rb
krates-1.6.4 lib/kontena/cli/master/token/common.rb
krates-1.6.3 lib/kontena/cli/master/token/common.rb
krates-1.6.2 lib/kontena/cli/master/token/common.rb