zero-to-prod / spapi-lwa
Connect to Amazons Selling Partner API with Login With Amazon (LWA).
Fund package maintenance!
Github
Installs: 1 817
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: >=7.1
- ext-curl: *
- ext-json: *
- zero-to-prod/container: ^0.1.0
- zero-to-prod/curl-helper: ^1.0
- zero-to-prod/factory: ^0.1.0
- zero-to-prod/package-helper: ^1.1.3
Requires (Dev)
- phpunit/phpunit: <12.0
This package is auto-updated.
Last update: 2025-09-01 22:42:29 UTC
README
Contents
- Introduction
- Requirements
- Installation
- Documentation Publishing
- Usage
- Testing
- Local Development
- Contributing
Introduction
Connect to Amazons Selling Partner API with Login With Amazon ( LWA).
Requirements
- PHP 7.1 or higher.
Installation
Install Zerotoprod\SpapiLwa
via Composer:
composer require zero-to-prod/spapi-lwa
This will add the package to your project's dependencies and create an autoloader entry for it.
Documentation Publishing
You can publish this README to your local documentation directory.
This can be useful for providing documentation for AI agents.
This can be done using the included script:
# Publish to default location (./docs/zero-to-prod/spapi-lwa) vendor/bin/zero-to-prod-spapi-lwa # Publish to custom directory vendor/bin/zero-to-prod-spapi-lwa /path/to/your/docs
Automatic Documentation Publishing
You can automatically publish documentation by adding the following to your composer.json
:
{ "scripts": { "post-install-cmd": [ "zero-to-prod-spapi-lwa" ], "post-update-cmd": [ "zero-to-prod-spapi-lwa" ] } }
Usage
Access Toke from Refresh Token
Use this for calling operations that require authorization from a selling partner. All operations that are not grantless operations require authorization from a selling partner. When specifying this value, include the rrefresh_token parameter.
use Zerotoprod\SpapiLwa\SpapiLwa; $response = SpapiLwa::from('client_id','client_secret') ->refreshToken('refresh_token'); $access_token = $response['response']['access_token'];
Access Token from Scope
Use this for calling grantless operations. When specifying this value, include the scope parameter.
use Zerotoprod\SpapiLwa\SpapiLwa; $response = SpapiLwa::from('client_id','client_secret') ->clientCredentials('scope'); $access_token = $response['response']['access_token'];
Testing
You can test the api by faking the response:
use Zerotoprod\SpapiLwa\SpapiLwa; use Zerotoprod\SpapiLwa\Support\Testing\SpapiLwaResponseFactory; $response = SpapiLwaResponseFactory::factory() ->asRefreshTokenResponse() ->make() SpapiLwaFake::fake($response); SpapiLwa::from('client_id', 'client_secret')
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.