Method: Dina::Authentication#header

Defined in:
lib/dina/authentication/authentication.rb

#headerString

Gets, sets, and renews a Bearer access token as required and produces a Bearer string

Returns:

  • (String)

    the Bearer token



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/dina/authentication/authentication.rb', line 67

def header
  if access_token.nil? || refresh_token.nil?
    get_token
  end

  if Time.now >= Time.parse(auth_expiry)
    renew_token
  end

  "Bearer " + access_token
end