class Firebase::Admin::Credentials

Firebase credentials.

Attributes

credentials[R]

Gets the google credentials

Public Class Methods

from_default() click to toggle source

Loads application default credentials.

@return [Firebase::Admin::Credentials]

# File lib/firebase/admin/credentials.rb, line 44
def from_default
  new(Google::Auth.get_application_default(SCOPE))
end
from_file(file) click to toggle source

Loads google credentials from a specified file path.

@param [File, String] file

The credentials file path

@return [Firebase::Admin::Credentials]

# File lib/firebase/admin/credentials.rb, line 25
def from_file(file)
  json = file.is_a?(File) ? file.read : File.read(file)
  from_json(json)
end
from_json(json) click to toggle source

Loads google credentials from a JSON string.

@param [String] json

A JSON string containing valid google credentials.

@return [Firebase::Admin::Credentials]

# File lib/firebase/admin/credentials.rb, line 36
def from_json(json)
  io = StringIO.new(json)
  new(Google::Auth::DefaultCredentials.make_creds(scope: SCOPE, json_key_io: io))
end
new(credentials) click to toggle source

Constructs a Credential from the specified Google Credentials.

@param [Google::Auth::ServiceAccountCredentials, Google::Auth::UserRefreshCredentials, Google::Auth::GCECredentials] credentials

The google credentials to connect with.
# File lib/firebase/admin/credentials.rb, line 56
def initialize(credentials)
  raise ArgumentError, "credentials cannot be nil" if credentials.nil?
  @credentials = credentials
end

Public Instance Methods

apply!(hash, opts = {}) click to toggle source

Apply the credentials

# File lib/firebase/admin/credentials.rb, line 67
def apply!(hash, opts = {})
  @credentials.apply!(hash, opts)
end
project_id() click to toggle source

Gets the google project id

# File lib/firebase/admin/credentials.rb, line 62
def project_id
  @credentials.project_id
end