File: string_token_provider.rb

package info (click to toggle)
ruby-ms-rest 0.7.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 424 kB
  • sloc: ruby: 693; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# encoding: utf-8
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

module MsRest
  #
  # Class that provides access to authentication token.
  #
  class StringTokenProvider < TokenProvider

    private

    # @return [String] the access token.
    attr_accessor :token

    # @return [String] the token type.
    attr_accessor :token_type

    public

    #
    # Creates and initalizes a new instance of StringTokenProvider class.

    # @param token [String] the access token.
    # @param token_type [String] the token type.
    #
    def initialize(token, token_type = TokenCredentials::DEFAULT_SCHEME)
      @token = token
      @token_type = token_type
    end

    #
    # Returns the string value which needs to be attached
    # to HTTP request header in order to be authorized.
    #
    # @return [String] authentication headers.
    def get_authentication_header
      "#{token_type} #{token}"
    end
  end
end