{"id":16399911,"url":"https://github.com/jwilsson/php-auto-refresh-oauth2-token-plugin","last_synced_at":"2026-02-24T11:03:00.201Z","repository":{"id":57003466,"uuid":"444841878","full_name":"jwilsson/php-auto-refresh-oauth2-token-plugin","owner":"jwilsson","description":"HTTPlug plugin to automatically refresh expired OAuth2 access tokens.","archived":false,"fork":false,"pushed_at":"2024-11-21T17:51:16.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T05:04:10.483Z","etag":null,"topics":["httplug","oauth2","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwilsson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-01-05T14:51:21.000Z","updated_at":"2024-11-21T17:51:20.000Z","dependencies_parsed_at":"2024-01-21T13:28:48.769Z","dependency_job_id":"1dd8540a-d722-4624-bcf3-cf1e054fc7e7","html_url":"https://github.com/jwilsson/php-auto-refresh-oauth2-token-plugin","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"f4a3c93bb7eec616fbdb79feb9563806c8fe119f"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilsson%2Fphp-auto-refresh-oauth2-token-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilsson%2Fphp-auto-refresh-oauth2-token-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilsson%2Fphp-auto-refresh-oauth2-token-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilsson%2Fphp-auto-refresh-oauth2-token-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwilsson","download_url":"https://codeload.github.com/jwilsson/php-auto-refresh-oauth2-token-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248323542,"owners_count":21084526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["httplug","oauth2","php"],"created_at":"2024-10-11T05:26:11.080Z","updated_at":"2026-02-24T11:03:00.189Z","avatar_url":"https://github.com/jwilsson.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP AutoRefreshOAuth2TokenPlugin\n[![Packagist](https://img.shields.io/packagist/v/jwilsson/auto-refresh-oauth2-token-plugin.svg)](https://packagist.org/packages/jwilsson/auto-refresh-oauth2-token-plugin)\n![build](https://github.com/jwilsson/php-auto-refresh-oauth2-token-plugin/workflows/build/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/jwilsson/php-auto-refresh-oauth2-token-plugin/badge.svg?branch=main)](https://coveralls.io/r/jwilsson/php-auto-refresh-oauth2-token-plugin?branch=main)\n\nA [HTTPlug plugin](https://docs.php-http.org/en/latest/plugins/introduction.html) to automatically refresh expired OAuth2 access tokens.\n\n## Requirements\n* PHP 8.4 or later.\n* [jwilsson/oauth2-client](https://github.com/jwilsson/php-oauth2-client) library.\n\n## Installation\nVia Composer:\n\n```sh\ncomposer require jwilsson/auto-refresh-oauth2-token-plugin\n```\n\n## Usage\nThis assumes you have an instantiated Refresh Token grant and Token object from the [jwilsson/oauth2-client](https://github.com/jwilsson/php-oauth2-client) library. A full Token object complete with access token, refresh token, and expiry information is expected.\n\n```php\nuse Http\\Client\\Common\\PluginClient;\nuse JWilsson\\AutoRefreshOAuth2TokenPlugin;\n\n$autoRefreshOAuth2TokenPlugin = new AutoRefreshOAuth2TokenPlugin(\n    $token,\n    $refreshTokenGrant,\n    $options, // Options for the plugin, see below\n    $refreshTokenOptions // Additional options to pass to RefreshToken::requestAccessToken()\n);\n\n$pluginClient = new PluginClient(\n    $myHttpClient,\n    [$autoRefreshOAuth2TokenPlugin]\n);\n\n$response = $pluginClient-\u003esendRequest($myRequest);\n\n// Remember to grab the token object after each call, it might have been updated with new information\n$refreshedToken = $autoRefreshOAuth2TokenPlugin-\u003egetToken();\n```\n\n### Options\n* `threshold` - Threshold in seconds for how close to the token's expiry time it should be considered expired. Default is 300 (5 minutes).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwilsson%2Fphp-auto-refresh-oauth2-token-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwilsson%2Fphp-auto-refresh-oauth2-token-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwilsson%2Fphp-auto-refresh-oauth2-token-plugin/lists"}