protected function RestfulAuthenticationToken::extractTokenFromRequest in RESTful 7
Extracting the token from a request by a key name, either dashed or not.
Parameters
$param_name: The param name to check.
array $request: The current request.
Return value
string The token from the request or FALSE if token isn't exists.
2 calls to RestfulAuthenticationToken::extractTokenFromRequest()
- RestfulAuthenticationToken::applies in modules/
restful_token_auth/ plugins/ authentication/ RestfulAuthenticationToken.class.php - Determines if the request can be checked for authentication. For example, when authenticating with HTTP header, return FALSE if the header values do not exist.
- RestfulAuthenticationToken::authenticate in modules/
restful_token_auth/ plugins/ authentication/ RestfulAuthenticationToken.class.php - Authenticate the request by trying to match a user.
File
- modules/
restful_token_auth/ plugins/ authentication/ RestfulAuthenticationToken.class.php, line 20 - Contains RestfulAuthenticationToken.
Class
- RestfulAuthenticationToken
- @file Contains RestfulAuthenticationToken.
Code
protected function extractTokenFromRequest(array $request = array(), $param_name) {
$key_name = !empty($param_name) ? $param_name : 'access_token';
$dashed_key_name = str_replace('_', '-', $key_name);
// Access token may be on the request, or in the headers
// (may be a with dash instead of underscore).
if (!empty($request['__application'][$key_name])) {
return $request['__application'][$key_name];
}
elseif (!empty($request[$key_name])) {
return $request[$key_name];
}
elseif (!empty($request['__application'][$dashed_key_name])) {
return $request['__application'][$dashed_key_name];
}
elseif (!empty($request[$dashed_key_name])) {
return $request[$dashed_key_name];
}
// Access token with that key name isn't exists.
return FALSE;
}