zero-to-prod/spapi-lwa

Connect to Amazons Selling Partner API with Login With Amazon (LWA).

v4.0.2 2025-02-02 00:00 UTC

This package is auto-updated.

Last update: 2025-02-20 19:29:46 UTC


README

Repo GitHub Actions Workflow Status GitHub Actions Workflow Status Packagist Downloads php Packagist Version License wakatime Hits-of-Code

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.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.