{"id":15296349,"url":"https://github.com/contamobi/pmobi-oauth2-php-client","last_synced_at":"2026-01-05T12:53:32.223Z","repository":{"id":56957523,"uuid":"131634813","full_name":"contamobi/pmobi-oauth2-php-client","owner":"contamobi","description":null,"archived":false,"fork":false,"pushed_at":"2018-05-02T13:37:50.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T05:26:37.416Z","etag":null,"topics":["guzzlehttp","middleware","oauth2-client","php71"],"latest_commit_sha":null,"homepage":null,"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/contamobi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-30T18:56:51.000Z","updated_at":"2018-05-02T13:29:46.000Z","dependencies_parsed_at":"2022-08-21T08:50:58.348Z","dependency_job_id":null,"html_url":"https://github.com/contamobi/pmobi-oauth2-php-client","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contamobi%2Fpmobi-oauth2-php-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contamobi%2Fpmobi-oauth2-php-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contamobi%2Fpmobi-oauth2-php-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contamobi%2Fpmobi-oauth2-php-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contamobi","download_url":"https://codeload.github.com/contamobi/pmobi-oauth2-php-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407755,"owners_count":20610232,"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":["guzzlehttp","middleware","oauth2-client","php71"],"created_at":"2024-09-30T18:10:11.309Z","updated_at":"2026-01-05T12:53:32.183Z","avatar_url":"https://github.com/contamobi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"### pague.MOBI Oauth2 Middleware\n\nThis is GuzzleHttp Middleware for pague.MOBI Oauth2. Based on [Guzzle OAuth 2.0 Subscriber](https://github.com/kamermans/guzzle-oauth2-subscriber).\n\n##### Usage\n\nWith classes\n```php\n\u003c?php\n\nuse GuzzleHttp\\Client;\nuse GuzzleHttp\\HandlerStack;\nuse kamermans\\OAuth2\\OAuth2Middleware;\nuse Pmobi\\Oauth2\\GrantType\\PmobiCredentials;\n\n$authClient = new Client([\n    \"base_uri\" =\u003e \"https://anything.p.mobi/oauth2/token\",\n]);\n\n$authConfig = [\n    \"client_id\" =\u003e \"your-client-id\",\n    \"client_secret\" =\u003e \"your-client-secret\",\n    \"username\" =\u003e \"your-username\",\n    \"password\" =\u003e \"your-password\",\n];\n\n$grantType = new PmobiCredentials($authClient, $authConfig);\n$oauth = new OAuth2Middleware($grantType);\n$stack = HandlerStack::create();\n$stack-\u003epush($oauth);\n\n$client = new Client([\n    'handler' =\u003e $stack,\n    'auth' =\u003e 'oauth',\n]);\n\n$response = $client-\u003erequest(\n    'get',\n    'https://anything.p.mobi/anywhere',\n    [\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n        ],\n    ]\n);\n\nvar_dump($response-\u003egetBody()-\u003egetContents());\n```\n\nWith Pmobi Middleware\n```php\n\u003c?php\n\nuse GuzzleHttp\\Client;\nuse Pmobi\\Oauth2\\Middleware as PmobiOauth2Middleware;\n\n$authConfig = [\n    \"token_url\" =\u003e \"https://anything.p.mobi/oauth2/token\",\n    \"client_id\" =\u003e \"your-client-id\",\n    \"client_secret\" =\u003e \"your-client-secret\",\n    \"username\" =\u003e \"your-username\",\n    \"password\" =\u003e \"your-password\",\n];\n\n// Optional\n$authConfig[\"token_filepath\"] = \"/tmp/access_token.json\";\n\n$stack = PmobiOauth2Middleware::createFromConfig($reauthConfig);\n\n$client = new Client([\n    'handler' =\u003e $stack,\n    'auth' =\u003e 'oauth',\n]);\n\n$response = $client-\u003erequest(\n    'get',\n    'https://anything.p.mobi/anywhere',\n    [\n        'headers' =\u003e [\n            'Content-Type' =\u003e 'application/json',\n        ],\n    ]\n);\n\nvar_dump($response-\u003egetBody()-\u003egetContents());\n```\n\nToken persistence\n```php\n\u003c?php\n\nuse kamermans\\OAuth2\\OAuth2Middleware;\nuse kamermans\\OAuth2\\Persistence\\FileTokenPersistence;\n\n/* ... */\n\n$tokenPersistence = new FileTokenPersistence(\"/tmp/access_token.json\");\n\n$oauth = new OAuth2Middleware($grantType);\n$oauth-\u003esetTokenPersistence($tokenPersistence);\n\n```\n\nMore information about persistence in [https://github.com/kamermans/guzzle-oauth2-subscriber#access-token-persistence](https://github.com/kamermans/guzzle-oauth2-subscriber#access-token-persistence). ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontamobi%2Fpmobi-oauth2-php-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontamobi%2Fpmobi-oauth2-php-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontamobi%2Fpmobi-oauth2-php-client/lists"}