Class: Parse::Middleware::Authentication

Inherits:
Faraday::Middleware
  • Object
show all
Includes:
Protocol
Defined in:
lib/parse/client/authentication.rb

Overview

This middleware handles sending the proper authentication headers to the Parse REST API endpoint.

Constant Summary

Constants included from Protocol

Protocol::API_KEY, Protocol::APP_ID, Protocol::CONTENT_TYPE, Protocol::CONTENT_TYPE_FORMAT, Protocol::EMAIL, Protocol::INSTALLATION_ID, Protocol::MASTER_KEY, Protocol::PASSWORD, Protocol::REVOCABLE_SESSION, Protocol::SERVER_URL, Protocol::SESSION_TOKEN

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, options = {}) ⇒ Authentication

Returns a new instance of Authentication

Parameters:

  • adapter (Faraday::Adapter)

    An instance of the Faraday adapter used for the connection. Defaults Faraday::Adapter::NetHttp.

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

    the options containing Parse authentication data.

Options Hash (options):

  • :application_id (String)

    the application id.

  • :api_key (String)

    the REST API key.

  • :master_key (String)

    the Master Key for this application. If it is set, it will be sent on every request unless this middleware sees DISABLE_MASTER_KEY as an entry in the headers section.

  • :content_type (String)

    the content type format header. Defaults to Protocol::CONTENT_TYPE_FORMAT.


40
41
42
43
44
45
46
# File 'lib/parse/client/authentication.rb', line 40

def initialize(adapter, options = {})
  super(adapter)
  @application_id = options[:application_id]
  @api_key = options[:api_key]
  @master_key = options[:master_key]
  @content_type = options[:content_type] || CONTENT_TYPE_FORMAT
end

Instance Attribute Details

#api_keyString

Returns the REST API Key for this Parse endpoint.

Returns:

  • (String)

    the REST API Key for this Parse endpoint.


23
24
25
# File 'lib/parse/client/authentication.rb', line 23

def api_key
  @api_key
end

#application_idString

Returns the application id for this Parse endpoint.

Returns:

  • (String)

    the application id for this Parse endpoint.


21
22
23
# File 'lib/parse/client/authentication.rb', line 21

def application_id
  @application_id
end

#master_keyString

The Master key API Key for this Parse endpoint. This is optional. If provided, it will be sent in every request.

Returns:


27
28
29
# File 'lib/parse/client/authentication.rb', line 27

def master_key
  @master_key
end