Module: Fastlane::Auth::FirebaseAppDistributionAuthClient

Constant Summary collapse

TOKEN_CREDENTIAL_URI =
"https://oauth2.googleapis.com/token"
REDACTION_EXPOSED_LENGTH =
5
REDACTION_CHARACTER =
"X"
SCOPE =
"https://www.googleapis.com/auth/cloud-platform"
CLIENT_ID =

In this type of application, the client secret is not treated as a secret. See: developers.google.com/identity/protocols/OAuth2InstalledApp

"563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com"
CLIENT_SECRET =
"j9iVZfS8kkCEFUPaAeJV0sAi"

Instance Method Summary collapse

Instance Method Details

#get_authorization(google_service_path, firebase_cli_token, google_service_json_data, debug = false) ⇒ Object

Returns an authorization object for any of the auth methods (Firebase CLI token, Application Default Credentials, firebase-tools). To ensure that a specific auth method is used, unset all other auth variables/parameters to nil/empty

args

google_service_json_data - Google service account json file content as a string
google_service_path - Absolute path to the Google service account file
firebase_cli_token - Refresh token
debug - Whether to enable debug-level logging

env variables

FIREBASE_TOKEN - see firebase_cli_token

Crashes if given invalid or missing credentials



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fastlane/plugin/firebase_app_distribution/helper/firebase_app_distribution_auth_client.rb', line 32

def get_authorization(google_service_path, firebase_cli_token, google_service_json_data, debug = false)
  if !google_service_path.nil? && !google_service_path.empty?
    UI.message("🔐 Authenticating with --service_credentials_file path parameter: #{google_service_path}")
    (google_service_path, debug)
  elsif !google_service_json_data.nil? && !google_service_json_data.empty?
    UI.message("🔐 Authenticating with --service_credentials_json content parameter")
    (google_service_json_data, debug)
  elsif !firebase_cli_token.nil? && !firebase_cli_token.empty?
    UI.message("🔐 Authenticating with --firebase_cli_token parameter")
    firebase_token(firebase_cli_token, debug)
  elsif !ENV["FIREBASE_TOKEN"].nil? && !ENV["FIREBASE_TOKEN"].empty?
    UI.message("🔐 Authenticating with FIREBASE_TOKEN environment variable")
    firebase_token(ENV["FIREBASE_TOKEN"], debug)
  elsif (refresh_token = refresh_token_from_firebase_tools)
    UI.message("🔐 Authenticating with cached Firebase CLI credentials")
    firebase_token(refresh_token, debug)
  elsif !application_default_creds.nil?
    UI.message("🔐 Authenticating with Application Default Credentials")
    application_default_creds
  else
    UI.user_error!(ErrorMessage::MISSING_CREDENTIALS)
    nil
  end
end