Module: Google::IdentityToolkit::Helpers

Defined in:
lib/google/identity_toolkit/helpers.rb

Instance Method Summary collapse

Instance Method Details

#account_chooser(element_id, options = {}) ⇒ String

Generate javascript for configuring the identity toolkit button

Parameters:

  • element_id (String) —

    Id of element that will contain the login button

  • options (Hash) (defaults to: {}) —

    Configuration options

Options Hash (options):

  • :api_key (String) —

    APIKey from developer console

  • :company_name (String) —

    Name of site to display on login pages

  • :base_url (String)

Returns:

  • (String) —

    Block of javascript (must be wrapped in

    
    
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    # File 'lib/google/identity_toolkit/helpers.rb', line 47
    
    def show_current_user(options={})
      js = ""
      user = options[:user] || Google::IdentityToolkit.current_user
      if user
        js = <<-EOF
        window.google.identitytoolkit.updateSavedAccount({
          email: '#{user[:email]}',
          displayName: '#{user[:display_name]}',
          photoUrl: '#{user[:photo_url]}'
        });
        window.google.identitytoolkit.showSavedAccount('#{user[:email]}');
        EOF
      end
      js
    end