Skip to content

Commit 13cd0ca

Browse files
committed
Merge pull request #204 from ushahidi/missing-token-message
Add a new "missing_token" exception message to Resource server
2 parents da92410 + f03e4a9 commit 13cd0ca

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/League/OAuth2/Server/Resource.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Resource
8484
0 => 'invalid_request',
8585
1 => 'invalid_token',
8686
2 => 'insufficient_scope',
87+
3 => 'missing_token',
8788
);
8889

8990
/**
@@ -94,6 +95,7 @@ class Resource
9495
'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.',
9596
'invalid_token' => 'The access token provided is expired, revoked, malformed, or invalid for other reasons.',
9697
'insufficient_scope' => 'The request requires higher privileges than provided by the access token. Required scopes are: %s.',
98+
'missing_token' => 'The request is missing an access token in either the Authorization header or the %s request parameter.',
9799
);
98100

99101
/**
@@ -109,6 +111,7 @@ class Resource
109111
'invalid_request' => 400,
110112
'invalid_token' => 401,
111113
'insufficient_scope' => 403,
114+
'missing_token' => 400,
112115
);
113116

114117
/**
@@ -387,7 +390,7 @@ public function determineAccessToken($headersOnly = false)
387390
}
388391

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

393396
return $accessToken;

0 commit comments

Comments
 (0)