{"id":16809711,"url":"https://github.com/startz/oauth2-etsy","last_synced_at":"2025-04-11T01:22:47.747Z","repository":{"id":59340314,"uuid":"536725227","full_name":"startz/oauth2-etsy","owner":"startz","description":"StartZ oauth2-etsy compatible League of PHP OAuth2","archived":false,"fork":false,"pushed_at":"2025-01-13T22:13:22.000Z","size":26,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T22:32:08.459Z","etag":null,"topics":["authorization","etsy","oauth2","oauth2-client","openapi","package","php8"],"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/startz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["cdburgess"]}},"created_at":"2022-09-14T19:11:49.000Z","updated_at":"2025-01-13T22:13:25.000Z","dependencies_parsed_at":"2025-02-18T11:31:56.412Z","dependency_job_id":null,"html_url":"https://github.com/startz/oauth2-etsy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startz%2Foauth2-etsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startz%2Foauth2-etsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startz%2Foauth2-etsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/startz%2Foauth2-etsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/startz","download_url":"https://codeload.github.com/startz/oauth2-etsy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247238511,"owners_count":20906459,"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":["authorization","etsy","oauth2","oauth2-client","openapi","package","php8"],"created_at":"2024-10-13T10:13:40.446Z","updated_at":"2025-04-11T01:22:47.728Z","avatar_url":"https://github.com/startz.png","language":"PHP","funding_links":["https://github.com/sponsors/cdburgess"],"categories":[],"sub_categories":[],"readme":"# Etsy Provider for OAuth 2.0 Client\n[![GitHub tag](https://img.shields.io/github/tag/startz/oauth2-etsy.svg)](https://github.com/startz/oauth2-etsy/blob/master/tags)\n[![GitHub license](https://img.shields.io/github/license/startz/oauth2-etsy.svg)](https://github.com/startz/oauth2-etsy/blob/main/LICENSE)\n[![build](https://github.com/startz/oauth2-etsy/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/startz/oauth2-etsy/actions/workflows/php.yml)\n[![codecov](https://codecov.io/gh/startz/oauth2-etsy/branch/master/graph/badge.svg)](https://codecov.io/gh/startz/oauth2-etsy)\n![Packagist Downloads](https://img.shields.io/packagist/dt/startz/oauth2-etsy)\n\nThis package provides Etsy OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).\n\n## Requirements\n\nThe following versions of PHP are supported.\n\n* PHP 7.3\n* PHP 7.4\n* PHP 8.0\n\n## Installation\n\nTo install, use composer:\n\n```\ncomposer require startz/oauth2-etsy\n```\n\n## Usage\n\nUsage is the same as The League's OAuth client, using `\\StartZ\\OAuth2\\Client\\Provider\\Etsy` as the provider.\n\nPlease refer to your [Etsy Developer Account](https://www.etsy.com/developers/your-apps) for the necessary settings.\n### Authorization Code Flow\n\n```php\n\u003c?php\n\nsession_start();\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n$provider = new Startz\\OAuth2\\Client\\Provider\\Etsy([\n    'clientId'     =\u003e '{etsy-apikey-keystring}',\n    'clientSecret' =\u003e '{etsy-apikey-shared-secret}',\n    'redirectUri'  =\u003e 'https://example.com/callback-url',\n]);\n\nif ( ! isset($_GET['code'])) \n{\n    // If we don't have an authorization code then get one\n    $preChallenge = $provider-\u003egetPreChallenge();\n    $authUrl = $provider-\u003egetAuthorizationUrl([\n        'code_challenge' =\u003e $provider-\u003egetPKCE($preChallenge),\n        'code_challenge_method' =\u003e 'S256'\n    ]);\n    $_SESSION['oauth2state'] = $provider-\u003egetState();\n    $_SESSION['oauth2code'] = $preChallenge;\n    header('Location: ' . $authUrl);\n    exit;\n\n// Check given state against previously stored one to mitigate CSRF attack\n} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {\n\n    unset($_SESSION['oauth2state']);\n    unset($_SESSION['oauth2code']);\n    exit('Invalid state');\n\n} else {\n    \n    $preChallenge = $_SESSION['oauth2code'];\n    $authParams = [\n        'code' =\u003e $_GET['code'],\n        'code_verifier' =\u003e $preChallenge,\n    ];\n    // Try to get an access token (using the authorization code grant)\n    $token = $provider-\u003egetAccessToken('authorization_code', $authParams);\n\n    // Optional: Now you have a token you can look up a users profile data\n    try {\n\n        // We got an access token, let's now get the user's details\n        $user = $provider-\u003egetResourceOwner($token);\n        printf('Hello %s!', $user-\u003egetName());\n\n    } catch (Exception $e) {\n\n        // Failed to get user details\n        exit('Error...');\n    }\n\n    // Use this to interact with an API on the users behalf\n    echo $token-\u003egetToken();\n}\n```\n\n## Testing\n\nUnit Tests\n``` bash\n$ ./vendor/bin/phpunit\n```\n\nCode Sniff\n```bash\n$ ./vendor/bin/phpcs src --standard=psr2 -sp\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstartz%2Foauth2-etsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstartz%2Foauth2-etsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstartz%2Foauth2-etsy/lists"}