Feature summary (what you would like to be able to do and where):
As a developer working on a library to let other developers use MediaWiki with OAuth 2.0, I would like to be able to get an access token with a much shorter TTL than usual, so that I can test automatic token refresh behavior without having to wait as long for the token to expire.
Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
My m3api-oauth2 library supports automatically refreshing the access token upon encountering an mwoauth-invalid-authorization error. The integration test for this feature currently sleeps for four hours to let the access token expire naturally ($wgOAuth2GrantExpirationInterval is PT4H in production). This rather slows down development, so I’d love to have some way to get a token with a much shorter expiration time.
Benefits (why should this be implemented?):
It would make my life, and potentially the life of other developers working on OAuth 2.0 libraries, easier :)
Other notes:
I’m pretty sure we want to keep $wgOAuth2GrantExpirationInterval as an upper limit on the expiration interval, and only allow clients to optionally lower it, not to give themselves tokens that are valid for years and years.
As far as I’m concerned, the shorter expiration could be a property of a specific OAuth consumer or be specified when requesting a particular access token. I was hoping that the latter would be relatively easy to implement (just add something like x_mediawiki_expiration_interval to the form data being posted to the access_token endpoint), but looking at where the expiration is currently set (in src/AuthorizationProvider/AuthorizationProvider.php, nowhere near src/Rest/Handler/AccessToken.php AFAICT) I’m not so optimistic anymore :/