Skip to content

Commit

Permalink
Merge pull request #204 from ushahidi/missing-token-message
Browse files Browse the repository at this point in the history
Add a new "missing_token" exception message to Resource server
  • Loading branch information
alexbilbie committed Sep 8, 2014
2 parents da92410 + f03e4a9 commit 13cd0ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/League/OAuth2/Server/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Resource
0 => 'invalid_request',
1 => 'invalid_token',
2 => 'insufficient_scope',
3 => 'missing_token',
);

/**
Expand All @@ -94,6 +95,7 @@ class Resource
'invalid_request' => 'The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the "%s" parameter.',
'invalid_token' => 'The access token provided is expired, revoked, malformed, or invalid for other reasons.',
'insufficient_scope' => 'The request requires higher privileges than provided by the access token. Required scopes are: %s.',
'missing_token' => 'The request is missing an access token in either the Authorization header or the %s request parameter.',
);

/**
Expand All @@ -109,6 +111,7 @@ class Resource
'invalid_request' => 400,
'invalid_token' => 401,
'insufficient_scope' => 403,
'missing_token' => 400,
);

/**
Expand Down Expand Up @@ -387,7 +390,7 @@ public function determineAccessToken($headersOnly = false)
}

if (empty($accessToken)) {
throw new Exception\MissingAccessTokenException(self::$exceptionMessages['invalid_request'], 0);
throw new Exception\MissingAccessTokenException(sprintf(self::$exceptionMessages['missing_token'], $this->tokenKey), 3);
}

return $accessToken;
Expand Down

0 comments on commit 13cd0ca

Please sign in to comment.