-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK-3268] Add bearer token extraction helper #620
Conversation
$cache->save($item); | ||
|
||
$response->cached = $cache; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a convenience addition for our test suite; now returns a pre-configured JWKS cache suitable for testing a given key, rather than having to redundantly do this within each test individually. Adds a little overhead to each test run that generates a token, but not significant enough to outweigh the convenience.
@evansims I am just looking for a native way to get the Bearer token and found your update. Great that this is already implemented. When will this update be available via composer? Is it part of the next Release 8.2.0? |
@ca-dsgn Apologies, somehow overlooked your reply! 8.2 has just been released today, which includes this method. 👍 Please do let me know any feedback you might have on how it works |
@evansims Is there already an example on how to use the getBearerToken() function? I tried several ways, but I am always getting null back from the function. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR adds a new method to the SDK class,
getBearerToken()
. This method is highly configurable and enable a developer to pull an available bearer token from a request from a variety of sources (request parameters, post body, etc.) while avoiding writing considerable and redundant boilerplate code.Example usage:
This would fetch and process an available access token from either an incoming GET request via a parameter named 'token', or from the request's “Authorization” header, where it might find a bearer token. The method silently ignores invalid or missing tokens from any provided candidate.
The PR adds several new tests to add coverage for the new method. Code coverage remains at 100%.