zero-to-prod / spapi-lwa
Connect to Amazons Selling Partner API with Login With Amazon (LWA).
Fund package maintenance!
Github
Installs: 1 205
Dependents: 5
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
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
Requires (Dev)
- phpunit/phpunit: <12.0
- zero-to-prod/package-helper: ^1.0
README
Contents
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.
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.