Skip to main content

GF_REST_Authentication

REST API authentication class.

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:15

Details

  • Kind: class
  • Namespace: (global)

Properties

PropertyTypeDescription
$errorWP_ErrorAuthentication error.
$userstdClassLogged in user data.
$auth_methodstringCurrent auth method.

Methods

MethodDescription
__construct()Initialize authentication actions.
override_rest_authentication_errors()If request is to our API and we did not set any authentication errors, override authentication errors that may
authenticate()Authenticate user.
authentication_fallback()Authenticate the user if authentication wasn't performed during the determine_current_user action.
check_authentication_error()Check for authentication error.
parse_header()Parse the Authorization header into parameters.
get_authorization_header()Get the authorization header.
get_oauth_parameters()Get oAuth parameters from $_GET, $_POST or request header.
send_unauthorized_headers()If the consumer_key and consumer_secret $_GET parameters are NOT provided
check_user_permissions()Check for user permissions and register last access.
urlencode_rfc3986()Encodes a value according to RFC 3986.
log_error()Write an error message to the Gravity Forms API log.
log_debug()Write a debug message to the Gravity Forms API log.

Method Reference

__construct()

public function __construct()

Initialize authentication actions.

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:49

override_rest_authentication_errors()

public function override_rest_authentication_errors( $errors )

If request is to our API and we did not set any authentication errors, override authentication errors that may

be set by other REST API authenticators.

Parameters

NameTypeDefaultDescription
$errors

Returns

  • null

Since: 2.4-beta-1

Deprecated: 2.4.22

Source: includes/webapi/v2/class-gf-rest-authentication.php:81

authenticate()

public function authenticate( $user_id )

Authenticate user.

Parameters

NameTypeDefaultDescription
$user_idint | falseUser ID if one has been determined, false otherwise.

Returns

  • int | false — Returns the User ID of the authenticated user.

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:132

authentication_fallback()

public function authentication_fallback( $error )

Authenticate the user if authentication wasn't performed during the determine_current_user action.

Necessary in cases where wp_get_current_user() is called before Gravity Forms is loaded.

Parameters

NameTypeDefaultDescription
$errorWP_Error | null | boolError data.

Returns

Since: 2.4.22

Source: includes/webapi/v2/class-gf-rest-authentication.php:172

check_authentication_error()

public function check_authentication_error( $error )

Check for authentication error.

Parameters

NameTypeDefaultDescription
$errorWP_Error | null | boolError data.

Returns

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:200

parse_header()

public function parse_header( $header )

Parse the Authorization header into parameters.

Parameters

NameTypeDefaultDescription
$headerstringAuthorization header value (not including "Authorization: " prefix).

Returns

  • array — Map of parameter values.

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:373

get_authorization_header()

public function get_authorization_header()

Get the authorization header.

On certain systems and configurations, the Authorization header will be stripped out by the server or PHP. Typically this is then used to generate PHP_AUTH_USER/PHP_AUTH_PASS but not passed on. We use getallheaders here to try and grab it out instead.

Returns

  • string — Authorization header if set.

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:404

get_oauth_parameters()

public function get_oauth_parameters()

Get oAuth parameters from $_GET, $_POST or request header.

Returns

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:429

send_unauthorized_headers()

public function send_unauthorized_headers( $response )

If the consumer_key and consumer_secret $_GET parameters are NOT provided

and the Basic auth headers are either not present or the consumer secret does not match the consumer key provided, then return the correct Basic headers and an error message.

Parameters

NameTypeDefaultDescription
$responseWP_REST_ResponseCurrent response being served.

Returns

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:802

check_user_permissions()

public function check_user_permissions( $result, $server, $request )

Check for user permissions and register last access.

Parameters

NameTypeDefaultDescription
$resultmixedResponse to replace the requested version with.
$serverWP_REST_ServerServer instance.
$requestWP_REST_RequestRequest used to generate the response.

Returns

  • mixed

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:821

urlencode_rfc3986()

public function urlencode_rfc3986( $value )

Encodes a value according to RFC 3986.

Supports multidimensional arrays.

Parameters

NameTypeDefaultDescription
$valuestring | arrayThe value to encode.

Returns

  • string | array — Encoded values.

Since: 2.4-beta-1

Source: includes/webapi/v2/class-gf-rest-authentication.php:853

log_error()

public function log_error( $message )

Write an error message to the Gravity Forms API log.

Parameters

NameTypeDefaultDescription
$messagestringThe message to be logged.

Since: 2.4.11

Source: includes/webapi/v2/class-gf-rest-authentication.php:868

log_debug()

public function log_debug( $message )

Write a debug message to the Gravity Forms API log.

Parameters

NameTypeDefaultDescription
$messagestringThe message to be logged.

Since: 2.4.11

Source: includes/webapi/v2/class-gf-rest-authentication.php:879