{"id":16994608,"url":"https://github.com/znerol/oauth2-server-storeauth-grant","last_synced_at":"2026-02-13T09:52:21.516Z","repository":{"id":244754147,"uuid":"815128338","full_name":"znerol/oauth2-server-storeauth-grant","owner":"znerol","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-24T11:05:11.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T14:39:27.352Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/znerol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T12:13:17.000Z","updated_at":"2025-02-24T11:04:51.000Z","dependencies_parsed_at":"2025-02-24T12:21:20.291Z","dependency_job_id":"9e14ac92-4ff2-48b1-a6d9-4deb09e32a5f","html_url":"https://github.com/znerol/oauth2-server-storeauth-grant","commit_stats":null,"previous_names":["znerol/oauth2-server-storeauth-grant"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/znerol/oauth2-server-storeauth-grant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znerol%2Foauth2-server-storeauth-grant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znerol%2Foauth2-server-storeauth-grant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znerol%2Foauth2-server-storeauth-grant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znerol%2Foauth2-server-storeauth-grant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/znerol","download_url":"https://codeload.github.com/znerol/oauth2-server-storeauth-grant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znerol%2Foauth2-server-storeauth-grant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29400615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-10-14T03:46:03.822Z","updated_at":"2026-02-13T09:52:21.481Z","avatar_url":"https://github.com/znerol.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Google Billing / Apple StoreKit OAuth2 Grant Extension for PHP OAuth 2.0 Server\n===============================================================================\n\nAn OAuth 2 [extension grant][rfc6749-4.5] which validates a Google Billing purchase or an Apple StoreKit transaction and returns an access token restricted to the specified SKU/product.\n\nDependencies\n------------\n\nSome PSR-18 HTTP client.\n\nFlow (Android Billing)\n----------------------\n\nThe client sends a POST request with following body parameters to the authorization server:\n\n* `grant_type` with the value `urn:uuid:ea31e77f-cb72-486f-b5c4-deef43e839f3`\n* `client_id` with the client’s ID\n* `scope` with a space-delimited list of requested scope permissions\n* `purchase_token` with the android billing purchase token\n\nThe authorization server will respond with a JSON object containing the following properties:\n\n* `token_type` with the value `Bearer`\n* `expires_in` with an integer representing the TTL of the access token\n* `access_token` a JWT signed with the authorization server’s private key\n\nFlow (Apple StoreKit)\n---------------------\n\nThe client sends a POST request with following body parameters to the authorization server:\n\n* `grant_type` with the value: `urn:uuid:c7e545a5-d72b-4294-a173-bb1858aae099`\n* `client_id` with the client’s ID\n* `scope` with a space-delimited list of requested scope permissions\n* `transaction_id` with the StoreKit transaction id\n\nThe authorization server will respond with a JSON object containing the following properties:\n\n* `token_type` with the value `Bearer`\n* `expires_in` with an integer representing the TTL of the access token\n* `access_token` a JWT signed with the authorization server’s private key\n\nSetup\n-----\n\nWherever you initialize your objects, initialize a new instance of the authorization server and bind the storage interfaces and authorization code grant:\n\n```PHP\n// Init our repositories\n$clientRepository = new ClientRepository(); // instance of ClientRepositoryInterface\n$scopeRepository = new ScopeRepository(); // instance of ScopeRepositoryInterface\n$accessTokenRepository = new AccessTokenRepository(); // instance of AccessTokenRepositoryInterface\n\n// Path to public and private keys\n$privateKey = 'file://path/to/private.key';\n//$privateKey = new CryptKey('file://path/to/private.key', 'passphrase'); // if private key has a pass phrase\n$encryptionKey = 'lxZFUEsBCJ2Yb14IF2ygAHI5N4+ZAUXXaSeeJm6+twsUmIen'; // generate using base64_encode(random_bytes(32))\n\n// Setup the authorization server\n$server = new \\League\\OAuth2\\Server\\AuthorizationServer(\n    $clientRepository,\n    $accessTokenRepository,\n    $scopeRepository,\n    $privateKey,\n    $encryptionKey\n);\n```\n\nFor google non-consumables:\n\n```PHP\n// Init non-consumable product repository\n$productRepository = ProductRepository() // instance of NonConsumableRepositoryInterface\n\n// Init google client factory\n$googleClientFactory = GoogleClientFactory() // instance of GoogleProductPurchaseFactoryInterface\n\n// Enable the Android purchases product grant on the server\n$packageName = 'com.some.thing';\n$clientCredentials = // path to google api service account client credentials\n$server-\u003eenableGrantType(\n    new \\StoreAuth\\OAuth2\\Server\\Grant\\GoogleNonConsumable($productRepository, $googleClientFactory),\n    new \\DateInterval('PT1H') // access tokens will expire after 1 hour\n);\n```\n\nFor apple non-consumables:\n\n```PHP\n// Init non-consumable product repository\n$productRepository = ProductRepository() // instance of NonConsumableRepositoryInterface\n\n// Init apple client factory\n$appleClientFactory = AppleClientFactory() // instance of AppleMostRecentTransactionFactoryInterface\n\n// Enable the Apple transactions grant on the server\n$server-\u003eenableGrantType(\n    new \\StoreAuth\\OAuth2\\Server\\Grant\\AppleNonConsumable($productRepository, $appleClientFactory),\n    new \\DateInterval('PT1H') // access tokens will expire after 1 hour\n);\n```\n\nLicense\n-------\n\n[MIT License][mit]\n\n[rfc6749-4.5]: https://datatracker.ietf.org/doc/html/rfc6749#section-4.5\n[mit]: https://opensource.org/license/mit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fznerol%2Foauth2-server-storeauth-grant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fznerol%2Foauth2-server-storeauth-grant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fznerol%2Foauth2-server-storeauth-grant/lists"}