# Class RESTian_Auth_Provider_Base

#### Direct known subclasses

RESTian_Basic_Http_Auth_Provider, RESTian_Not_Applicable_Provider
Abstract
Located at base-classes/class-auth-provider.php

Methods summary
`public` | # `__construct( `RESTian_Client` $api )` #### Parameters $api ``RESTian_Client`` $api
`public array` | # `prepare_credentials( array $credentials )` Allow auth provider to process credentials Allow auth provider to process credentials #### Parameters $credentials `array` $credentials #### Returns `array`
`public array` | # `prepare_grant( array $grant, array $credentials )` Allow auth provider to process grant Allow auth provider to process grant #### Parameters $grant `array` $grant $credentials `array` $credentials #### Returns `array`
`public array` | # `get_new_credentials( )` #### Returns `array`
`public array` | # `get_new_grant( )` #### Returns `array`
`public boolean` | # `is_credentials( array $credentials )` Determine if provided credentials represent a viable set of credentials Determine if provided credentials represent a viable set of credentials Default behavior ensures that all credential elements exist, i.e. if username and password are required this code ensures both username and password have a value. Subclasses can add or relax requirements using their own algorithms as required. #### Parameters $credentials `array` $credentials #### Returns `boolean`
`public boolean` | # `is_grant( array $grant )` Determine if provided grant represents a viable grant Determine if provided grant represents a viable grant Default behavior ensures that all grant elements exist, i.e. if access_token and refresh_token are required this code ensures both access_token and refresh_token have a value. Subclasses can add or relax requirements using their own algorithms as required. #### Parameters $grant `array` $grant #### Returns `boolean`
`public array` | # `extract_grant( array $auth_settings )` Extract grant from the passed $auth_settings. Extract grant from the passed $auth_settings. #### Parameters $auth_settings `array` $auth_settings #### Returns `array`
`public array` | # `extract_credentials( array $auth_settings )` Extract credentials from the passed $auth_settings. Extract credentials from the passed $auth_settings. #### Parameters $auth_settings `array` $auth_settings #### Returns `array`
`public boolean` | # `has_prerequisites( array $credentials )` Test to see if the request has prerequisites required to authenticate, i.e. credentials. Test to see if the request has prerequisites required to authenticate, i.e. credentials. Defaults to making sure that the request has valid credentials; subclasses can modify as required. #### Parameters $credentials `array` $credentials #### Returns `boolean`
`public` | # `prepare_request( `RESTian_Request` $request )` Allows an auth provider to decorate a RESTian_Request prior to $request->make_request(), as required. Allows an auth provider to decorate a RESTian_Request prior to $request->make_request(), as required. #### Parameters $request ``RESTian_Request`` $request
`public boolean` | # `handle_response( `RESTian_Response` $response )` Allows an auth provider to handle a response; returns true if handled, false otherwise. Allows an auth provider to handle a response; returns true if handled, false otherwise. The auth provider does not have to handle every response. #### Parameters $response ``RESTian_Response`` $response #### Returns `boolean`
`public` | # `capture_grant( `RESTian_Response` $response )` Takes the response and capture the grant in the format $this->is_grant() will validate Takes the response and capture the grant in the format $this->is_grant() will validate #### Parameters $response ``RESTian_Response`` $response
`public boolean` | # `authenticated( `RESTian_Response` $response )` Tests a RESTian_Response returning true if the response was authenticated, false otherwise. Tests a RESTian_Response returning true if the response was authenticated, false otherwise. Default is an HTTP 200 or 204 status code; subclasses can modify as required. #### Parameters $response ``RESTian_Response`` $response #### Returns `boolean` #### See: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success
`public string` | # `get_error_message( string $code )` Return an error message Return an error message #### Parameters $code `string` $code #### Returns `string`
`protected boolean` | # `_has_required( array $pattern_array, array $array_to_test )` Tests an array to ensure it has all required elements given a pattern array. Tests an array to ensure it has all required elements given a pattern array. #### Parameters $pattern_array `array` $pattern_array $array_to_test `array` $array_to_test #### Returns `boolean` #### Examples: $pattern = array( 'a' => '', 'b' => '', 'c' => '' ); $array = array( 'a' => 'foo', 'b' => 'bar', 'd' => 'baz' ); $this->_has_required( $pattern, $array ) // returns false because !isset($array['c']) $pattern = array( 'a' => '', 'b' => '', 'c' => '' ); $array = array( 'a' => 'foo', 'b' => 'bar', 'c' => 'baz', 'd' => 'bezong' ); $this->_has_required( $pattern, $array ) // returns true because !isset($array['d']) is irrelevant.

Properties summary
`public `RESTian_Client`` | $api | `` | #
`public string` | $auth_type | `` | # RESTian-specific authorization type identifier, like 'basic_http', etc. RESTian-specific authorization type identifier, like 'basic_http', etc.
`public string` | $auth_version | `` | # To contain something like '1.0a', to be set by subclass if needed. To contain something like '1.0a', to be set by subclass if needed.
`public string` | $message | `` | # Allows auth provider to set a user readable message Allows auth provider to set a user readable message