Sha256: 6c95c9026c884055773f0a784bb6f94a537c3bae01ad53d26d61e8be01a9e313
Contents?: true
Size: 1 KB
Versions: 24
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module FmRest module V1 module Auth ACCESS_TOKEN_HEADER = "X-FM-Data-Access-Token" # Requests a token through basic auth # # @param connection [Faraday] the auth connection to use for # the request # @return The token if successful # @return `false` if authentication failed def request_auth_token(connection = FmRest::V1.auth_connection) request_auth_token!(connection) rescue FmRest::APIError::AccountError false end # Requests a token through basic auth, raising # `FmRest::APIError::AccountError` if auth fails # # @param (see #request_auth_token) # @return The token if successful # @raise [FmRest::APIError::AccountError] if authentication failed def request_auth_token!(connection = FmRest.V1.auth_connection) resp = connection.post(V1.session_path) resp.headers[ACCESS_TOKEN_HEADER] || resp.body["response"]["token"] end end end end
Version data entries
24 entries across 24 versions & 1 rubygems